I want to iterate over an array of objects that I get from a REST service and create a dynamic form using a directive ng-repeat.
This is my form with a rating directive (taken for the UI Bootstrap library)
<form name="categoryRatingFrom" data-ng-submit="updateCategories(catRatings) >
<div data-ng-repeat="cats in categories" class="form-group clearfix">
<label class="control-label">{{ cats.name }}</label>
<div class="no-outline"
data-rating
data-ng-model=" // Here I want to concatenate {{ cats.id }} with the ng-model name catRatings // "
data-max="6"
data-rating-states="ratingOptions.ratingStates"
data-on-hover="atmosphereRating.onHover(value)"
data-on-leave="atmosphereRating.onLeave()"></div>
</div>
<form>
I want to set the value data-ng-modelusing the name of the object that I transmit when sending, and the identifier of the current object tin my loop / array, however I seem to be unable to do this. Do I have to concatenate in the controller when getting an array of objects using a loop, and then set the ng data model using the value from ng-repeat. Nothing is passed to the controller when the form is submitted (see My code below):
for (var i = 0, l = $scope.categories.length; i < l; i++) {
$scope.categories[i]['modelId'] = 'catRatings.' + $scope.categories[i].id;
}
HTML data-ng-model="cats.modelId", - - , ?