I have a ng-repeat, and I have to update "frais" of all values displayed by ng-repeat. this code update only last value. how can I do to update all, please?
file.html
<ion-content class="padding" ng-controller="FactureAdminCtrl" ng-repeat = "selectedName in selected">
<ion-list ng-repeat = "selectedName in selected">
<div class="item item-divider center-text" name="codeE" ng-model="selectedName.CodeEnvoiColis"> {{selectedName.CodeEnvoiColis}} </div>
<label class="item item-input">
<input width="20%" type="text" placeholder="Frais" ng-model="selectedName.FraisFact" style="color:#BA1B1B;"></div>
</label>
</ion-list>
<a class="button button-info" href="#/factureAdmin" ng-click=updateFact(selectedName)> Submit </a>
app.js
$scope.updateFact = function(selectedName){
$http.post(
"http://localhost/deb/insertFact.php",
{
'FraisFact':$scope.selectedName.FraisFact,
'CodeEnvoiColis':$scope.selectedName.CodeEnvoiColis,
}
).success(function(data){
alert(data);
});
}
You have to use unique model or name for HTML elements
look at this simple example:
<ion-list ng-repeat = "selectedName in selected">
<input type="text" class="form-control" ng-model="doc.title[$index]" name="doc_{{$index}}">
</ion-list>
<ion-content class="padding" ng-controller="FactureAdminCtrl" ng-repeat = "selectedName in selected">
<ion-list ng-repeat = "selectedName in selected track by $index">
<div class="item item-divider center-text" name="codeE" ng-model="selectedName.CodeEnvoiColis" > {{selectedName.CodeEnvoiColis}} </div>
<label class="item item-input">
<input width="20%" type="text" placeholder="Frais" data-comment= "selectedName.FraisFact" ng-model="FraisFact[$index]" name="FraisFact{{$index}}" style="color:#BA1B1B;"></div>
</label>
</ion-list>
<a class="button button-info" href="#/factureAdmin" ng-click=insertFact(selectedName)> Ajouter </a>