We are preparing for upgrading our AngularJS app and refactoring for that. Currently we are running into an architectural issue:
Our app currently loads JSON through a jQuery AJAX call, this sets up all of the data and then bootstraps the app.
We need to move the AJAX call to Angular however, so that we can bootstrap the app without waiting for the AJAX to return (which is necessary for the upgrade)
$.get('/ajax/init').done(function (initData) {
walletApp.run([
'SomeService', function (someService) {
// ...
},
]);
walletApp.config([
'SomeProvider', function (someProvider) {
// ...
},
]);
walletApp
.factory('navInfo', function () {
return initData.navInfo;
})
.factory('userInfo', function () {
return initData.userInfo;
});
// ETC
// Below is the important line
angular.bootstrap(document, ['walletApp']);
});
I've been trying something along the lines of the below, where the initService
gets the JSON feed and then assigns all of the data
angular.module('walletApp')
.run([
'InitService', function (initService) {
initService.get();
},
]);
angular.bootstrap(document, ['walletApp']);
But this results in a bunch of issues.
How do we properly load our AngularJS app, that requires data from AJAX to operate?