Utilizing this function allows me to retrieve all my data from the web service.
public data: Data[];
getall() {
this.ws.getalldata().subscribe(
data=> {
this.data= data;
}
);
}
Here is a snippet from the Json file:
{
"StatusCode": 0,
"StatusMessage": "OK",
"StatusDescription": [
{
"id": "1",
"id_type": 1,
"desc": "TRTY",
"active": 0,
},
....
{
"id": "3",
"id_type": 50,
"desc": "qqq",
"active": 0,
},
{
"id": "4",
"id_type": 50,
"desc": "qqq",
"active": 0,
},
......
{
"id": "30",
"id_type": 2,
"desc": "hhh",
"active": 0,
}
}
To display this data in html, you can use the following code:
<StackLayout *ngFor="let item of data">
<Label row="1" col="1" text="" class="list-group-item-text" [text]='item.id_type'></Label>
<Label row="1" col="1" text="" class="list-group-item-text" [text]='item.desc'></Label>
</StackLayout>
Now, I am looking for a way to display only the top 5 elements in the template. How can I achieve this?