In your controller, change your page object to this:
$scope.page = { displayedPage: function(num) { if(arguments.length) { $scope.page.pageNumber = num - 1; return num; } else { return $scope.page.pageNumber + 1; } }, pageNumber: 0 }
And then you do the following:
<input type="text" ng-model="page.displayedPage" ng-model-options="{ getterSetter: true}" />
This will display the page number plus 1, but leave the actual page.pageNumber variable the way it should be.
The getterSetter: true parameters that I added will bind the model to the getter / setter function, which allows you to pass an argument - in this case, the entered page number - and return from this function. You can read more about this in the documentation for ngModel
millerbr
source share