Hi
According to John Papa Guideline, it is better to use $inject to manually
identify dependencies for Angular components
<https://github.com/johnpapa/angular-styleguide#style-y091>.
What should be the best practice for the following code
angular
.module('app')
.factory('factory1', ['$http', factory1])
.factory('factory2', ['factory1', '$http', '$q', factory2])
.factory('factory3', ['factory2', '$http', '$q', factory3]);
var service = {};
function factory1($http) {
return $http.get('config.json')
.then (function(response) {
service.siteID = response.data._id;
return service.siteID
});
}
function factory2(factory1, $http, $q) {
return factory1
.then(function(value) {
return $http.get('/api/sites/' + value)
.then (function(response) {
service.template = response.data.template;
return service.template;
})
})
}
function factory3(factory2, $http, $q) {
return factory2
.then(function(value) {
return $http.get('/api/sites/' + value)
.then (function(response) {
service.pages = response.data.pages;
return service.pages;
})
})
}...
Should I do FactoryName.$inject = [] for all of them?
Regards
Greg
--
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.