I'm utterly stumped about this one:
I've got a property, pageSize, that is originally set in the controller, but can be updated through a select box. When I change the select box, data-bindings in the view get updated, but not the one in the controller's scope, and I don't understand why.
Everything else works fine. I've got only one controller that does everything else it's supposed to do. I'm calling update() from ng-change which works fine. And in the update(), I log the value of $scope.pageSize, but that value never changes, despite the {{pageSize}} just above my select showing the new value.
How is this possible?
HTML:
{{pageSize}}
<select name="pageSize" id="pageSize" ng-model="pageSize" ng-change="update();">
<option value="5">5</option>
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
</select>
Controller:
$scope.update = function() {
console.log("pageSize = "+$scope.pageSize);
reviewService.fetch({
pageSize: $scope.pageSize,
}).success(function(data, status) {
console.log("success!");
$scope.reviewData = data.d;
$scope.nrOfPages = Math.ceil($scope.reviewData.summary.ReviewCount / $scope.pageSize);
}).error(function(data, status) {
console.log("error!");
$scope.error = true;
});
}
$scope.update();
So to be clear:
* $scope.update() gets called correctly by ng-change.
* the log($scope.pageSize) always logs '5'.
* {{pageSize}} shows the value I selected.
mcv.