There is a way to delay changing routes until the model is loaded using a resolve object.
See here for details:
Delay changing routes until model loaded
Is it possible do something similar for controllers (not using routes)? I would like to avoid the flicker associated with rendering a model that is retrieved asynchronously.
Something like:
var resolve = {
data1: function($http) {
return $http({ url:'/someurl1', method: 'GET'});
},
data2: function($http) {
return $http({url: '/someurl2', method: 'GET'});
}
};
// I know this doesn't exist, but you get the idea about what I'm trying to do.
app.resolvers(resolve);
// Then inject data1 and data2 into the controller.
// The controller should not load until data1 and data 2 have been resolved.
app.controller('myController', function($scope, data1, data2) { ... });