I am new to Angular js and want to set the global variable that I can use it on different different services as webservice url.
I have implemented app.js (module) like this:
var app;
(function () {
app = angular.module("ANG", []);
app.value('user', {
urlBase: ''
});
})();
When I want to use this constants values I just define it in the service defination and use it but I want to store the details in that so no need to set values again and again.
Example:
When I login in the system I return some data with webserviceurl with it and I set that url in the value.urlBase in login controller.
But when I go to different service and want to use that it sets the values back to ''.
CODE to use constant values:
app.service('servicename', ["$http", "$q", 'user', function ($http, $q, user) {
//access the user here but it gives value ''.
console.log(user.urlBase);
}
How can I store at once and use it again and again?