Petre Gabriel Petre Gabriel -5 years ago 707
AngularJS Question

How to load more elements with angular?

for a while I am trying to find how to make a load more(elements from an array) button,using Angular.

I have 9 elements in array, I use

to loop them, and
to output first 3.


1: is possible to make a load more button using only angular?(load more button is at bottom in example)

2: if not, how to make this work using jQuery?


Answer Source

You don't need to think of jQuery, as you could solve this problem easily by using AngularJS itself.

You could maintain a variable inside your controller, name it as limit, then increment the limit variable inside loadMore() function.


<div ng-repeat="elem in | limitTo:travel.limit" class="cruises">

  ....COntent here...



app.controller('TravelController', function($scope) {
    var vm = this; = cruises;
    vm.limit = 3;

    $scope.loadMore = function() {
      var increamented = vm.limit + 3;
      vm.limit = increamented > ? : increamented;

Demo Plunkr

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download