javascript - Use angularjs ng repeat $index to name model -
i dont know angular need put $index number inside ng-model , src path (_xxx) dont know how it. need $index number, me this?
i tried put {{$index}} not work...
<div ng-repeat='opt in el.options_final' for='radio{{$index}}'> <div class='img-radio'> <input id='image_location_{{$index}}' ng-model='el.image_xxx' /> <img src='{{el.image_xxx}'> </div> </div> thank you.
you need use bracket notation ng-model, ng-model="el['image_' + $index]" , use ng-src , append index, ng-src="{{el['image_' + $index]}}"
<input id='image_location_{{$index}}' ng-model="el['image_' + $index]" /> <img ng-src="{{el['image_' + $index}}"> why ng-src?
using angular markup {{hash}} in src attribute doesn't work right: browser fetch url literal text {{hash}} until angular replaces expression inside {{hash}}. ngsrc directive solves problem.
Comments
Post a Comment