我的范围上有一个模型,它是对象的对象。我已经看到了这个,但是我想从模板中执行此操作,因为我在其上定义了一个过滤器。
var App = angular.module('app', []);
App.controller('myCtrl', function($scope) {
$scope.items = {
{ name: 'Cricket bat', cost: '2500', quantity: 0},
{ name: 'Football', cost: '1100', quantity: 0}
};
$scope.cartItems = {}; // This holds the items. I want quantity of each item separately so it's not an array.
我已经定义了一个过滤器getPrice
来计算用户购物车中商品的价格。
我在模板中有:
{{ cartItems | getPrice }}
是否可以在任何嵌套对象值(即购物车中的一个项目的数量)更改后更新模板?如果是,如何?