angular.forEach(请参阅http://docs.angularjs.org/api/angular.forEach)函数中的最后一个参数是的上下文
this。因此,您需要这样的东西:
app.service('myService', function() { this.list = []; this.execute = function() { //this.list is reachable here angular.forEach(AnArrayHere, function(val, key) {//access this.list }, this); }}


