Currently I am working on a Bluemix app with an Angular frontend. I use an conf.json to declare some settings. I need that because my cústomer wants a white-label application which he can configure via an JSON file
So I need to load the config.json. I use ajax for that. My file to load it is conf.js:
var promise = $.Deferred();
$.getJSON("config.json", function (configjson){
promise.resolve(configjson);
return configjson;
});
I want to be sure, that the conf is loaded, when I start angular, because it uses some stuff out of it.
myApp.js starts Angular:
var myApp = angular.module("myApp",
['ui.router','diaNavbar','ngMaterial','dashboard']);
promise.done(function(config){
console.log("Config: ",config);
myApp.config(['$stateProvider','$urlRouterProvider','$logProvider','$mdThemingProvider',
function($stateProvider,$urlRouterProvider,$logProvider,$mdThemingProvider) {
// configure Angular with Conf.json
}]);
});
So my concept is, that the promise variable (jQuery) indicates, when the config is loaded. When I remove the promise.done function it works, but trows the errors, because config ist not loaded yet. The console.log throws out the config, so that works too. But in combination it doesnt work.
Working Environment: Bluemix, Node.JS Express 4, AngluarJS, JQuery,
I would appreciate any help on this