0
/**
* New node file
*/
var app = angular.module('myApp', []);
angular.module('myApp', []).controller('orderCtrl', function($scope) {
$scope.name = '';
$scope.price = '';
$scope.total=0;
$scope.output=0;
count=0;
$scope.items = [
{id:1, Name:'Garlic Bread',price:20 },
{id:2, Name:'Butter Chicken',price:30 },
{id:3, Name:'Tandoori Chicken',price:25 },
{id:4, Name:'Naan',price:5},
{id:5, Name:'Ice Cream',price:10},
{id:6, Name:'Pizza',price:15 }
];
$scope.cal=function(id){
$scope.output = $scope.output+$scope.items[id-1].price;
$scope.fina.push({id:$scope.items[id-1], Name:$scope.items[id-1].Name,price:$scope.items[id-1].price});
}
$scope.res=function(fina){
$scope.total= $scope.output;
$scope.finals=angular.copy($scope.fina);
}
});
推送函數拋出錯誤無法讀取屬性'push'的未定義的角度。我想繼續添加項目數組的內容到fina數組。有沒有其他的方法?angularjs:想將物品陣列推入到fina數組
向我們展示了小提琴上的代碼。 – amoeba
重複的http://stackoverflow.com/questions/351409/appending-to-array – frhd