使用filter和limitTo修复ng-repeat语法

时间:2017-05-10 13:43:01

标签: angularjs

我正在尝试使用ng-repeat加快我的limitTo:totalDisplayed,但是,由于我的语法,我收到了错误。有人可以帮我纠正一下吗?

ng-repeat="practice in vm.practices | filter: { orgName: vm.searchTerm } limitTo:totalDisplayed track by practice._id"

--- --- EDIT 这是错误

Error: [$parse:syntax] Syntax Error: Token 'limitTo' is an unexpected token at column 51 of the expression [vm.practices | filter: { orgName: vm.searchTerm } limitTo:totalDisplayed] starting at [limitTo:totalDisplayed].
http://errors.angularjs.org/1.5.7/$parse/syntax?p0=limitTo&p1=is%20an%20unexpected%20token&p2=51&p3=vm.practices%20%7CNaNilter%3A%20%7B%orgName%3A%20vm.searchTerm%20%7D%20limitTo%3AtotalDisplayed&p4=limitTo%3AtotalDisplayed
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:68:12
    at AST.throwError (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:14343:11)
    at AST.ast (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:14096:12)
    at ASTCompiler.compile (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:14559:31)
    at Parser.parse (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:15488:29)
    at $parse (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:15653:39)
    at ChildScope.$watchCollection (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:17056:30)
    at Object.ngRepeatLink (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:29503:16)
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:1240:18
    at invokeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:9814:9)
    at nodeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:9215:11)
    at compositeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:8510:13)
    at nodeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:9210:24)
    at compositeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:8510:13)
    at compositeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:8513:13)
    at compositeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:8513:13)
    at compositeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:8513:13)
    at compositeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:8513:13)
    at publicLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:8390:30)
    at Object.<anonymous> (https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.3.1/angular-ui-router.min.js:7:24081)
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:1240:18
    at invokeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:9814:9)
    at nodeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:9215:11)
    at compositeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:8510:13)
    at publicLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:8390:30)
    at lazyCompilation (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:8728:25)
    at l (https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.3.1/angular-ui-router.min.js:7:23072)
    at https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.3.1/angular-ui-router.min.js:7:23492
    at Scope.$broadcast (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:17767:28)
    at https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.3.1/angular-ui-router.min.js:7:18795
    at processQueue (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:16170:28)
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:16186:27
    at Scope.$eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:17444:28)
    at Scope.$digest (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:17257:31)
    at Scope.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:17552:24)
    at done (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:11697:47)
    at completeRequest (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:11903:7)
    at XMLHttpRequest.requestLoaded (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js:11836:9)
(anonymous) @ angular.js:13708
(anonymous) @ angular.js:10347
invokeLinkFn @ angular.js:9816
nodeLinkFn @ angular.js:9215
compositeLinkFn @ angular.js:8510
nodeLinkFn @ angular.js:9210
compositeLinkFn @ angular.js:8510
compositeLinkFn @ angular.js:8513
compositeLinkFn @ angular.js:8513
compositeLinkFn @ angular.js:8513
compositeLinkFn @ angular.js:8513
publicLinkFn @ angular.js:8390
(anonymous) @ angular-ui-router.min.js:7
(anonymous) @ angular.js:1240
invokeLinkFn @ angular.js:9814
nodeLinkFn @ angular.js:9215
compositeLinkFn @ angular.js:8510
publicLinkFn @ angular.js:8390
lazyCompilation @ angular.js:8728
l @ angular-ui-router.min.js:7
(anonymous) @ angular-ui-router.min.js:7
$broadcast @ angular.js:17767
(anonymous) @ angular-ui-router.min.js:7
processQueue @ angular.js:16170
(anonymous) @ angular.js:16186
$eval @ angular.js:17444
$digest @ angular.js:17257
$apply @ angular.js:17552
done @ angular.js:11697
completeRequest @ angular.js:11903
requestLoaded @ angular.js:11836

1 个答案:

答案 0 :(得分:0)

正如@Setily提到的那样,它是ng-repeat="practice in vm.practices | filter: { orgName: vm.searchTerm } | limitTo:totalDisplayed track by practice._id"

我的过滤器后错过了一个管道