Answer the question
In order to leave comments, you need to log in
How to generate ng-model dynamically in ng-repeat?
Is it possible to somehow form ng-model dynamically? So that in ng-repeat an individual ng-model is formed for each element.
For example: ng-model="document1 .. 2 .. 3 etc." by setting something like documents+id.
<div class="col-xs-12"
ng-repeat="doc in docsAttr">
<div class="form-group material form-md-line-input form-md-floating-label">
<input type="text" class="form-control"
id="{{ doc.id}}"
ui-mask="9999"
data-position="{{doc.position}}"
ng-model="doc+$index" />
<label for="{{ doc.alias }}">{{ doc.name }}</label>
<span class="help-block"> Например: {{ doc.example }} </span>
</div>
</div>
UserDocumentsAttr.getAttr().then(function(res){
$scope.docsAttr = res.data;
});
for (var i = 0; i <= 4; i++) {
docs.push({
id: $scope.docsAttr[i].id,
name: $scope.doc+i // Присвоить значение из ng-model
});
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question