Currently, I am facing the challenge of displaying a JavaScript object in an Angular ~1.2.24 template.
I want to display only the first occurrence of item.day.
Take a look at this sample object:
$scope.listtrail = [{
day: '2015-08-15',
id: 123,
timestamp: '2015-08-15 12:23:12'
},{
day: '2015-08-15',
id: 122,
timestamp: '2015-08-15 12:43:34'
},{
day: '2015-08-15',
id: 121,
timestamp: '2015-08-15 14:12:56'
},{
day: '2015-08-14',
id: 120,
timestamp: '2015-08-14 11:12:09'
},{
day: '2015-08-14',
id: 118,
timestamp: '2015-08-14 10:11:02'
}]
Here is an example of the desired output template section:
<div ng-repeat="item in listtrail">
<div>{{item.day}}</div>
<div>{{item.timestamp}}</div>
</div>
The expected result wanted from the template looks like this:
<div>
<div>2015-08-15</div>
<div>2015-08-15 12:23:12</div>
</div>
<div>
<div>2015-08-15 12:43:34</div>
</div>
<div>
<div>2015-08-15 14:12:56</div>
</div>
<div>
<div>2015-08-14</div>
<div>2015-08-14 11:12:09</div>
</div>
<div>
<div>2015-08-14 10:11:02</div>
</div>
Please bear in mind that the JavaScript array may grow and get updated periodically by an internal splice function.