javascript - AngularJs ng-repeat not working for incremental viewmodel values using $index -
<ul id="datalines"> <li data-ng-repeat="dataline in viewmodel.datalines"> <input type="text" value="{{dataline}}" id="data{{ $index +1 }}" data-ng-model="viewmodel.dataline{{ $index +1 }}" required> </li> </ul>
what trying achieve add multiple input lines depending upon datalines. there 3 main issues facing here overall related bigger feature trying get.
firstly view data-ng-model="viewmodel.dataline{{ $index +1 }}"
not working..(syntax error: token '{' unexpected)
secondly input value not getting prefilled value="{{dataline}}"
thirdly on viewmodel dont have viewmodel.dataline1, viewmodel.dataline2, viewmodel.dataline3 .... have no idea how edited input values on controller(viewmodel.dataline1 ...its undefined on contrl)
i not sure if handling module correctly. there better way of achieving kind of result in angular 2.0. article or blog guides in direction can help. -thanks
notation array , object variable keys in javascript []
try doing:
<li data-ng-repeat="dataline in viewmodel.datalines"> <input type="text" id="data{{ $index }}" data-ng-model="viewmodel.datalines[ $index ]" required> </li>
since have ng-model
shouldn't need valu
pointing same array element
there dsicrepeny between viewmodel.datalines
, viewmodel.dataline
in code uncertain about
Comments
Post a Comment