Hi Konstatin,
Just return the promise form the service, make use of the fact that
services only gets instantiated once. You can add as many .then's to a
promise as you need, it won't execute the promise anymore.
sample:
GetData.$inject=["$http"]
function GetData($http) {
var service = this;
var defaultUrl = "/goGetSomething"
service.getData = function (url) {
url = url || defaultUrl
service.prom = $http.get(url);
}
service.getData(defaultUrl)
return service
}
SomeController.$inject=["GetData"]
function SomeController(GetData) {
var vm = this;
getData.then(function (response) {
vm.whatever = response....
})
}
angular
.module('sample',[])
.service('GetData', GetData)
.controller('SomeController', SomeController)
Is that what you where looking for? This way you keep reusing the same
(already fulfilled) promise, while keeping the option open to reload the
data.
Regards
Sander
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.