I have a service
app.service(\'myService\', function() {
this.list = [];
this.execute = function() {
//this.list is reachable here
a
The last parameter in the angular.forEach
(See http://docs.angularjs.org/api/angular.forEach) function is the context for this
. So you'll want something like 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);
}
}