0
在代碼中,有ng-repeat,我必須更新由ng-repeat顯示的所有值的「frais」。此代碼只更新最後一個值。我該怎麼做才能更新所有內容?更新ng-repeat值angularJS和php
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/updatFact.php",
{
'FraisFact':$scope.selectedName.FraisFact,
'CodeEnvoiColis':$scope.selectedName.CodeEnvoiColis,
}
).success(function(data){
alert(data);
});
}
我該怎麼辦,請!
謝謝,但我不明白你的意思是哪個數組! – SalamSalam
'selected'是一個數組嗎?所以你必須發送這個數組到後端&進程 – DilumN
這是選中的函數:$ rootScope.selected = []; $ rootScope.namesF3 = []; $ rootScope.exist = function(item){ return $ rootScope.selected.indexOf(item)> -1; } $ rootScope.toggleSelection = function(item){ var x = []; var idx = $ rootScope.selected.indexOf(item); if(idx> -1){rootScope.selected.splice(idx,1); } else { $ rootScope.selected.push(item); } } – SalamSalam