I have an array
of string
that I want to bind to an array of input
s:
HTML:
<ul>
<li class="form-group" ng-repeat="remark in trip.remarks track by $index">
<label>Remarque {{$index + 1}}:</label>
<textarea class="form-control" type="text" ng-model="remark"></textarea>
</li>
<hr>
</ul>
<button ng-click="addRemark()" class="btn btn-success" style="width: 100%">Ajouter</button>`
In my controller I have already initialized the trip
object, and the binding does happen, but when I edit the data through the textarea
nothing changes in the trip
object.
The is how my controller is coded:
$scope.trip = productService.getCurrentTrip();
$scope.addRemark = function () {
$scope.trip.remarks.push("");
}
It seem the binding is happening only from the controller to the view, also when I click addRemark
button a new textarea
does appear. So can anyone tell me how can I bind back to the controller?
NB:
1)I also tried to bind to this controller using ng-model="trip.remarks[$index]"
but no use.
2) I have other fields in trip
object that are binded and working two-ways