.config([
'$provide',
function ($provide) {
'use strict';
var initInjector = angular.injector(['ng']);
var apiUrl;
initInjector.get('$http').get('customer/api/')
.then(function (response) {
console.log("dddd" + response.data.url);
apiUrl = response.data.url;
});
console.log(apiUrl);
//This print as Undefined
$provide.constant('GLOBAL', global);
}
]);
when i print the apiUrl value tetrived from http get service print as undefined.
can some one hep me to get the value of response.data.url to outer scope.
Edit:
var apiUrl;
var initInjector = angular.injector(['ng']);
var self = this;
initInjector.get('$http').get('customer/api/')
.then(function(response) {
console.log("ddddd" + response.data.url); //print value
self.apiUrl = response.data.url;
console.log("selff" +self.apiUrl); //print value
});
console.log("outerr" +self.apiUrl); // print undefined