I have an angular 1.4 application where I have a service that encapsulates the communication with my backend. If I do something like following to return data from an endpoint. The Api service that I'm injecting encapsulates my $http ajax requests
function MyDataService(Api, $injector, $q, $log) {
var self = this;
function getAll(){
return self.Api.get('/myData').then(function(data){
self.data = data;
return self.data;
})
}
return self;
}
If I use this service method in a controller or other modules, Am I referencing directly that property? I mean, if I do a double binding in a controller and that variable change, self.data inside my service will change too? I think JS is using references by default.
Thank you very much
selfyour service or your controller?