0
我有以下的角碼坐在一個角度控制器:AngularJS - 無法在範圍總結性
CODE:
$scope.orangeCrate.italian = {
"description": "Annual",
"payer": "farmer",
"farmerCost": 0,
"ownerCost": 21
};
$scope.orangeCrate.portugal = {
"description": "Annual",
"payer": "owner",
"farmerCost": 6.5,
"ownerCost": 0
};
$scope.orangeCrate.total = {
"farmerCost": $scope.orangeCrate.italian.farmerCost + $scope.orangeCrate.portugal.farmerCost,
"ownerCost": $scope.orangeCrate.italian.ownerCost + $scope.orangeCrate.portugal.ownerCost,
};
當我嘗試並打印出裏面的值$scope.orangeCrate.total.farmerCost
根據我的觀點,我什麼也沒得到,即使我應該得到6.5
!
我在做什麼錯?任何幫助將不勝感激。
謝謝。
是否'$ scope.orangeCrate'存在分配給前的'italian'和'葡萄牙「屬性(如果沒有,那麼JavaScript會拋出錯誤)?你如何引用視圖中的值?它似乎在這裏工作... http://jsfiddle.net/685SW/ –