I have a $scope
object that contains 50+ records. I have a <div>
that displays the first 5 records in this $scope
via a limitTo.
I have a button 'See More' that on each click displays the next 5 records.
However, once 50 records have been shown, i would like my button to call a function getMore()
which, on its as it stands on its own, gets another 50 records.
HTML:
<div ng-repeat="data in myData | limitTo: Limit" >
{{ data.name }}
</div>
<button ng-click="Limit = Limit + 5">
See More
</button>
<button ng-click="getMore()">
See More
</button>
JS:
app.controller("MyCtrl", function($scope) {
$scope.Limit = 5;
$scope.getMore = function () {
// Call service to get more data
};
});
How can i remove the need to have 2 buttons? But also, on call of getMore()
once another max of 50 results have been returned (or 34 for example) reveal 5 at a time?
Thanks