0

How would I change this:

ng-messages="createCourseForm.quizItemMultipleChoiceAnswer+$index.$error"

into:

ng-messages="createCourseForm.quizItemMultipleChoiceAnswer0.$error"
ryanyuyu
  • 6,366
  • 10
  • 48
  • 53
rtn
  • 2,012
  • 4
  • 21
  • 39
  • Possible duplicate of [Dynamically assign ng-model](http://stackoverflow.com/questions/14183614/dynamically-assign-ng-model) – Grundy Nov 12 '15 at 16:13

1 Answers1

1

It looks like you are trying to access a specifically named property from your form. If you need the property name to be variable, you can use javascript's bracket notation for accessing properties. Then you can pass in any string and access the property.

ng-messages="createCourseForm['quizItemMultipleChoiceAnswer' + $index].$error"
ryanyuyu
  • 6,366
  • 10
  • 48
  • 53