angularjs - How can we concat angular js variable with ng-model -
<div class="row" data-ng-repeat="i in [1,2,3,4]"> <div asterick class="form-group" ng-class="{'form-group has-success': !error['resource_type'] && (submitted), 'form-group has-error': (error['resource_type']) && (submitted)}"> <label for="resourcetype">resource type</label> <select name="resourcetype" id="resourcetype" ng-model="data.resource_type+{{ }}" ng-required="true" > <option ng-repeat="option in resourcetypejson" value="{{option}}">{{option}}</option> </select> </div> </div>
i trying access i (loop variable) ng-model. need resource_type1, resource_type2 , on. how can please help.
make resource type array instead of separate properties.
{ data: { resource_type1: 'data1', resource_type2: 'data2', resource_type3: 'data3' } }
becomes
{ data: { resource_type: ['data1', 'data2', 'data3'] } }
and can following in ngmodel:
ng-model="data.resource_type[i]"
what if can't above?
you can try following:
ng-model="data['resource_type' + i]"
Comments
Post a Comment