私はangularjs経由で投稿要求を出しています。Angularjs:最初のAJAXリクエストの後でng-modelバインディングが機能しない
<input class="form-control" ng-model="hotel.hotel_name" type="text">
<input class="form-control" ng-model="hotel.hotel_loc" type="text">
<input type="button" value="Submit" name="Submit" ng-click="addHotel(hotel)" class="btn btn-sm btn-primary">
コントローラ
$scope.addHotel=function(hotel){
$http({
method:"POST",
data:{'hotel':hotel},
url:base_url+'operator/hotel/add_hotel'
}).then(function serverResponse(response){
//clear the old form data
$scope.hotel=[];
})
}
正常に処理されたデータは、$scope.hotel=[]
古い形式のデータをクリアしかし、私はいくつかの値でフォームを再送信するとき、それは私がundefiend
を取得します読み取ることができないしたら
$scope.addHotel=function(hotel){
//undefiend
console.log(hotel);
}
注: 投稿は初めてで、応答は成功しましたが、それ以降は実行できません。
'scope'オブジェクトに' hotel'を定義しましたか? – brk
ホテルは配列ではないオブジェクトです$ scope.hotel = {} – Manish
@ user2181397:ビュー内のマークアップは – Paritosh