NgRepeat中LimitTo过滤器中的Dynamic Begin参数

时间:2016-07-04 15:32:39

标签: angularjs

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

我需要&#34; startFrom&#34;作为动态参数。 这里有许多类似的问题,但都没有解决。

1 个答案:

答案 0 :(得分:1)

这是一个代码片段:

&#13;
&#13;
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];
});
&#13;
<!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>
&#13;
&#13;
&#13;