Bharat D Bhadresha Bharat D Bhadresha - 4 months ago 46
AngularJS Question

Dynamic Begin parameter in LimitTo filter in NgRepeat

<div ng-repeat="tweet in twitts | limitTo : limitTo : startFrom">


I need "startFrom" as Dynamic parameter.
There are many similar questions here but all are unsolved.

Answer

Here's a snippet working:

var app = angular.module('app', []);

app.controller('mainCtrl', function ($scope) {
  $scope.array = [];
  for (var i = 1; i <= 1000; i+=10) {
    $scope.array.push(i);
  }
  $scope.startForm = $scope.array[2];
});
<!DOCTYPE html>
<html ng-app="app">

<head>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.7/angular.min.js"></script>      
</head>

<body ng-controller="mainCtrl">
  <select ng-options="obj as obj for obj in array" ng-model="startForm"></select>
  <ul>
    <li ng-repeat="obj in array | limitTo: startForm" ng-bind="obj"></li>
  </ul>
</body>

</html>

Comments