json file which contains my app_key and app_secret, I have written factory service to make available app_key and app_secret everywhere. but I am not getting in correct format, here is my factory method
.factory('UserService', function($http) {
var obj ={};
$http.get('config.json').success(function(data) {
obj.app_key = data.app_key;
obj.app_secret=data.app_secret;
})
console.log(obj);
return {
app_key : obj.app_key,
app_secret : obj.app_secret
}
})
Here is my config.json file
{
"url": "",
"app_key": "myappkeycode",
"app_secret": "appsecretcodehere"
}
I want my app key and app secret to be accessed everywhere with userService.app_key
and userService.app_secret
Whats wrong I am doing dont know I am getting object but in following format
Object {}
app_key:"appkeycoming keyhere",
app_secret:"appsecretcominghere"
Which is not working as you see first object is empty.
console.log(data)
inside the success function – Weedoze 15 hours ago