javascript - How to stall angular execution until JSON has been loaded? -
I have an angular application that needs to load app config data from some JSON, it is wrapped in a service, The problem that gets injected into the controllers is that I should wait until the controllers have successfully loaded json. In other words, load it synchronously. I want to request this json file and the app is not nothing until we get it back. I do not know what is the "proper angular" way to do this, suggestion? use Note :: angular Bootstrap () .
var myApp = angular.module ('myApp', []); // Announce your remaining app, e.g. MyApp.controller (... angular.element (.document) .ready (function () {jQuery.getJSON ('/ api / my-app / config', function (data) {// what you want with `data` Angular.bootstrap (document.getElementById ('my-app'), ['myApp']);});})
< Li> Feel free to use any other method to get your config JSON,
jQuery.getJSON ()
Comments
Post a Comment