0
我正在使用角度來填充可以編輯的表單。但編輯不會被範圍變量捕獲。在Ionic上使用角度綁定不起作用
這裏是我的代碼:
HTML代碼:
<div class="list">
<label class="item item-input">
<span class="input-label">Name</span>
<span>{{name}}</span>
</label>
<label class="item item-input">
<span class="input-label">Locality</span>
<span>{{locality}}</span>
</label>
<label class="item item-input">
<span class="input-label">City</span>
<span>{{city}}</span>
</label>
<label class="item item-input">
<span class="input-label">Amenities</span>
<input type="text" placeholder="Amenities" ng-model="amenities">
</label>
<label class="item item-input">
<span class="input-label">Total Rooms</span>
<input type="text" placeholder="Total Rooms" ng-model="trooms">
</label>
</div>
<div class="text-center">
<button class="button button-positive" ng-click="hotelUpdate()">
Save Edits
</button>
</div>
hotelUpdate():
$scope.hotelUpdate = function() {
var hotel1 = {
objectId: $state.params.hotelId,
amenities: $scope.amenities,
free_rooms: $scope.frooms,
total_rooms: $scope.trooms
}
Backendless.Data.of("Hotels").save(hotel1)
.then(function(savedObject){
console.log(savedObject);
})
.catch(function(error){
console.log(error);
})
}
}
是不是有什麼毛病的代碼?以前用同樣的方法使用綁定,它工作得很好。
你的代碼看起來不錯,問題應該是在你不顯示其他部分。請發佈所有信息 –
您還發布了類似的問題沒有迴應:https://stackoverflow.com/questions/45980477/binding-to-capture-changes-in-form-values。請在演示您的問題的Codepen,小提琴或其他在線編輯器中發佈演示 –