Currently I have a factory and a controller. The factory updates with items from an endpoint and the number of pages of data. My data
array is being recognized fine, but my pageCount
(int) update never actually changes. I have checked to make sure it isn't actually returning 0.
.factory('myService', function($http) {
return {
data: [],
update: update,
pageCount: 0
};
function update() {
return $http.get('path/to/endpoint')
.then(function(res) {
angular.copy(res.data.itemsArray, this.data);
angular.copy(res.data.pageCount, this.pageCount);
// also tried this.pageCount = res.data.pageCount;
}.bind(this));
}
})
.controller('myCtrl', function(myService) {
myService.update();
$scope.data = myService.data;
$scope.pageCount = myService.pageCount;
});
<div>{{pageCount}}</div> // This does not update at all
<div ng-repeat="item in data">{{item}}</div> // This works fine