Can you guide me on how to use ng-repeat to display a specific property from an object in an array? Specifically, I want to show the emails field.
Here is the JSON data:
[
{
"TypeId": 3,
"Type": "Listings",
"emails": [
"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3d4e52505858505c54510f7d58455c504d5158135e5250">[email protected]</a>",
"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ed9e82808888808c8481dead88958c809d8188c38e8280">[email protected]</a>",
"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="acdfc3c1c9c9c1cdc5c099ecc9d4cdc1dcc0c982cfc3c1">[email protected]</a>"
]
}
]
This is the corresponding Controller code:
myService.getEmails().then(function (emails) {
if (emails && emails.length) {
$scope.emailsList = emails
}
})
And here's how it would be implemented in HTML using AngularJS and ng-repeat:
<tr ng-repeat="item in emailsList['emails'] track by $index">
<td>
<div class="rounded-checkbox">
<input class="form-check-input" type="checkbox">
<span></span>
</div>
</td>
<td class="col-xs-12">{{ item }}</td>
<td>-</td>
</tr>