简体   繁体   English

AngularJS ng-repeat在过滤器中使用$ index

[英]AngularJS ng-repeat using $index in a filter

I'm using ng-repeat and trying to use the $index in a filter like this 我正在使用ng-repeat并尝试在这样的过滤器中使用$ index

<div data-ng-repeat="i in [1,2,3,4,5,6,7,8,9]">            
  <div ng-repeat="student in students | filter:{Surname:'Smith', Group: {{$index}}">
    <span ng-click="updateStudent(student.StudentID)">{{student.FullName}}</span>
  </div>
</div>

I'm getting a syntax error in the Chrome dev tools console. 我在Chrome开发工具控制台中遇到语法错误。 Is it possible to use $index like this? 有可能像这样使用$ index吗?

I have also tried Group: $index without the braces 我也试过Group:$ index没有大括号

你不需要双括号,因为你正在使用ng-repeat ,但你也错过了最后的}

ng-repeat="student in students | filter:{Surname:'Smith', Group: $index}"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM