ng-if inside ng-repeat in angularjs -
i generating dynamic form in angularjs:
<div ng-repeat="choice in mydata" class='repeater'> <div ng-if="choice.type === 'dropdown'" ng-init="count = 0"> <div class="row"> <div class="col-md-2"> <p>choose</p> </div> <div class="col-md-8"> <select ng-model="selected" ng-options="item.value item in mydatedropdown[count]"> </select> </div> </div> {{count += 1}} </div> </div>
i unable increment value of count , assign mydatedropdown[]
. new angularjs.
you try changing ng-repeat <div ng-repeat="(index, choice) in mydata" class='repeater'>
, use index
in mydatedropdown
<div ng-repeat="(index, choice) in mydata" class='repeater'> <div ng-if="choice.type === 'dropdown'" ng-init="count = 0"> <div class="row"> <div class="col-md-2"> <p>choose</p> </div> <div class="col-md-8"> <select ng-model="selected" ng-options="item.value item in mydatedropdown[index]"> </select> </div> </div> </div> </div>
Comments
Post a Comment