At the moment, I have a factory and a controller set up. The factory is responsible for updating with items retrieved from an endpoint along with the total number of pages of data. While my data
array seems to be working properly, the pageCount
(an integer) doesn't seem to update at all. I have double-checked to ensure that it is not returning a value of 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);
// I also attempted 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 still displays the initial value
<div ng-repeat="item in data">{{item}}</div> // This section is functioning correctly