1

I'm using ng-repeat and trying to use the $index in a filter like this

<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. Is it possible to use $index like this?

I have also tried Group: $index without the braces

3
  • 1
    You're missing } at the end of the ngRepeat Commented Jun 2, 2016 at 12:38
  • Aside from the missing } at the end, don't you mean filter:{Surname:'Smith', Group: i}? Commented Jun 2, 2016 at 12:39
  • Yes I think a combination of both of these is correct. Thanks Commented Jun 2, 2016 at 13:01

1 Answer 1

3

You don't need the double braces here, since you are using ng-repeat, but also you were missing a final }

ng-repeat="student in students | filter:{Surname:'Smith', Group: $index}"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.