angularjs - Angular Config Doesn't Work -


i have following code. console.log(apiserverconstants.url) line in factory returns undefined when inject authservice in other code. why?

angular.module("webclient.constants", []) .constant("apiserverconstants", {     "url": "http://localhost:8080" });  angular.module('webclient', [   // stuff   'webclient.constants'   ])   .config(     // code   });  angular.module('webclient')   .factory('authservice', ['$http', 'apiserverconstants', 'localstorageservice', function($http, localstorageservice, apiserverconstants) {      return {       authenticate: function(data) {         // code       },       login: function(data, apiserverconstants) {         console.log(data);         console.log(apiserverconstants.url);         // more code        }     } }]); 

you inverted injections.

['$http', 'apiserverconstants', 'localstorageservice', function($http, localstorageservice, apiserverconstants) should ['$http', 'localstorageservice', 'apiserverconstants', function($http, localstorageservice, apiserverconstants)

edit:

and why apiserverconstants parameter of login? try this:

login: function(data) {     console.log(apiserverconstants.url); } 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -