このようにメインビューにロードするパーシャルで新しいレコードを作成するためのフォームがあります
<div ng-controller="NewProductController">
<ng-include src=" 'views/partials/product-form.html' "></ng-include>
</div>
フォームには、いくつかの入力フィールドがあります
..
<input ng-model="cip" type="text" id="cip" class="form-control" placeholder="Enter the CIP" autofocus="autofocus"/>
<input ng-model="name" type="text" id="name" class="form-control" placeholder="Enter the name" />
私のコントローラーでは、入力フィールドの値を含む POST リクエストを送信しています。
...
.controller('NewProductController', function(Product, $scope) {
$scope.create = function () {
Product.create( {'cip': $scope.cip,
'name': $scope.name,
'dosage': $scope.dosage,
...
});
};
問題は、入力フィールドの値が変更されたとき、それがコントローラーに反映されないことです ($scope.cip と $scope.name は、何らかの値で初期化しない限り未定義です)。ただし、$scope.cip と $scope.名前がコントローラーで変更された場合、変更はビューに正しく反映されます。
その種の更新は自動的に行われると思いましたか、それとも何か不足していますか?