I am looking to utilize some data within an angular project instead of relying on a database due to its small size, consisting of about 50 id's with 5 fields. Here is the sample data:
mydata = [
{
"id": 3,
"active": 1,
"title": "Title 1",
"text": "this is some text from 3"
},
{
"id": 31,
"active": 1,
"title": "Title 1",
"text": "this is some text from 31"
},
{
"id": 11,
"active": 1,
"title": "Title 1",
"text": "this is some text for 11"
},
{
"id": 21,
"active": 1,
"title": "Title 1",
"text": "this is some text from 21"
}
]
Next, I have designed a method as follows:
getDataText(id) {
// code implementation to fetch the text based on the selected id
// this should provide me with the data (specifically the text for id 11)
}
In my component.html file, I have included this snippet:
<button (click)="getDataText(11)">Get Data by Id</button>
How can I achieve this functionality?