I am working on a project based on ionic and angular js. I am loading a JSON file containing some JSON data in key-value pairs. What I want to achieve is a call to the $ urlRouterProvider.otherwise () method after the json file is fully loaded. Below is the code I tried, but it does not work for me. I tried putting the console into the defaultRoute function that it executes, but this line doesn’t work with $ urlRouterProvider.otherwise ('/ tab / myjobs'). The following code is present in the app.config function. Any help would be appreciated.
$.getJSON('js/constants/'+lang+'.json')
.then(function(response) {
$translateProvider.translations(window.localStorage['deviceLanguage'],response);
defaultRoute($urlRouterProvider);
}, function(response) {
});
function defaultRoute($urlRouterProvider){
if(window.localStorage['userData']) {
var access_token = JSON.parse(window.localStorage['userData']).access_token;
if(access_token){
$urlRouterProvider.otherwise('/tab/myjobs');
}else{
$urlRouterProvider.otherwise('/login');
}
}else{
console.log("in line 282");
$urlRouterProvider.otherwise('/login');
}
}
source
share