【发布时间】:2017-04-24 01:51:15
【问题描述】:
我试图在一个简单的函数中总结几个数字。我遍历我的数字列表,可以从日志中看到我看到的每个数字。
然后我有以下内容,其中有一个 var 保存总和并应返回它。
但是什么也没发生!
代码如下:
angular.extend(self, {
getTotalGood : function(){
var total = 1;
angular.forEach( self.myproducts, function( value, key ){
console.log(key + ' : ' + value.product.cost);
total = value.product.cost;
})
return total;
}
})
self.getTotalGood();
【问题讨论】:
标签: angularjs angular-controller