I'm having an issue with my AngularJS ng-repeat when trying to display JSON data. The records are duplicating, but only after reloading the page. Initially, everything works fine.
Take a look at the JSON data below:
[{
"EmployeeName": "Jishnu",
"CategoryId": 0,
"Points": 76,
"DateAdded": "/Date(-62135596800000)/",
"DateModified": "/Date(-62135596800000)/",
"Id": 0
}, {
"EmployeeName": "Sini",
"CategoryId": 0,
"Points": 56,
"DateAdded": "/Date(-62135596800000)/",
"DateModified": "/Date(-62135596800000)/",
"Id": 0
}, ... and so on
Here is the snippet of AngularJS code:
angular.module('myApp', [])
.controller('ReportCtrl', ['$scope', '$http', '$window', function($scope, $http, $window) {
$scope.employeePoints = [];
$scope.searchText = [];
// Handle $http request here
}]);
And here's how it looks in HTML:
<tr ng-repeat="point in employeePoints">
<td>
<span class="name">{{point.EmployeeName}}</span>
</td>
<td class="hidden-phone">
{{point.Points}}
</td>
</tr>
Upon inspecting the console log, here's the response data from the web service:
[{"EmployeeName":"Jishnu","CategoryId":0,"Points":76,"DateAdded":"/Date(-62135596800000)/","DateModified":"/Date(-62135596800000)/","Id":280},{"EmployeeName":"Sini","CategoryId":0,"Points":56,"DateAdded":"/Date(-62135596800000)/","DateModified":"/Date(-62135596800000)/","Id":78}, ...]