0
如果我這樣做{{newStore1}}和$ scope.newStore1 ='貓頭鷹商店',當頁面加載時,文字說貓頭鷹商店。數據綁定的一切都很好。如果我做一個輸入框,並給它的模型newStoreName,那也有用,大部分...我的數據綁定工作,但我的輸入NG模型沒有更新時,我更新
{{newStore1}}
<form data-ng-submit="storeUpdate()">
<input type="text" ng-model="newStore1">
<input type="submit" />
</form>
新店名稱顯示爲空。即使正如我在文本框中輸入一樣,{{newStore}}會更新文本。但是當我這樣做時,它給了我一個空值。
$scope.storeUpdate = function(){
Users.get({email:$scope.global.user.email}, function(user3) {
user3[0].store.push($scope.newStore1); // $scope.newStore1 is working in html but is 'null' here
user3[0].$update(function(response) {
Users.query({}, function(users) {
$scope.users = users;
$scope.global.user = response;
});
});
});
};
總是在'ng-model'中有一個點,所以當範圍開始嵌套時你可以確保利用對象繼承。基元不會在嵌套的作用域中綁定 – charlietfl 2014-10-20 04:35:12
so data-ng-model =「store.name」? – 2014-10-20 04:37:48
如果我在ng模型名稱中加了一個點,當我點擊提交時,它會顯示「無法讀取未定義的屬性名稱」。 – 2014-10-20 04:41:45