I am using KnockoutJS to render a JSON. Certain results have more than 1 "Applications". Is it possible to make it in the foreach so that it only returns 1 only always? Whichever one comes first.
In example below, TEST1 has 2 results under Applications. I would just like to show one in the rendering.
HTML
<table>
<thead>
<tr>
<th>AppId</th>
<th>Name</th>
<th>App Token</th>
</tr>
</thead>
<tbody data-bind="foreach: { data: APPS, as: 'APP' }">
<tr data-bind="foreach: Applications">
<td><span data-bind="text: appId"></span></td>
<td><span data-bind="text: $parent.name"></span></td>
<td><span data-bind="text: AppToken"></span>
</tr>
</tbody>
</table>
JSON
{
"APPS":{
"bad":{
"Name":"TEST1",
"Applications":[
{
"AppId":"bab",
"AppToken":null
},
{
"AppId":"bab",
"AppToken":null
}
]
},
"good":{
"Name":"TEST2",
"Applications":[
{
"AppId":"bab",
"AppToken":null
}
]
}
}
}
data-bind="with: Applications[0]"instead offoreach?