0

In AngularJS I used Limit To, but on the Angular2 this function was removed.

Example:

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

Controller:

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

  $scope.loadMore = function() {
    var increamented = vm.limit + 3;
    vm.limit = incremented > vm.cruise.length ? vm.cruise.length :    increamented;
  };
});
Hugo Silva
  • 11
  • 4
  • 1
    What have you tried? This sounds like a simple task: incrementing a limit, and taking the N first elements of an array. – JB Nizet Dec 15 '16 at 17:30

1 Answers1

0

I guess you have to think of it as a function. Take a look at this.

<div *ngFor="let item of getItems(items, limit)">
</div>

getItems may apply caching to prevent multiple requests.

Or if the array is not lazy loaded. Try this.

<div *ngFor="let item of items | slice:0:limit">
</div>
hossein
  • 313
  • 1
  • 8