We have been using Angular for some weeks now to build out a wep application. After using it for some time I have just a few issues I could do with some help resolving.
We have controllers which are using for Admin screens which contain a lot of select boxes where the data is fetched using ngResource calls. Typically something akin to this:
.controller('AdminCustomController', ['$scope', '$routeParams', '$window', '$location','$q', 'countriesResource', 'titlesResource', 'townsResource', 'favcolorsResource', 'customersResource',
function ($scope, $routeParams, $window, $location, $q, countriesResource, titlesResource, townsResource, favcolorsResource, customersResource) {
$scope.loading = true;
$scope.customer = customersResource.get({id: 3});
$scope.titles = titlesResource.query();
$scope.towns = titlesResource.query();
$scope.colors = favcolorsResource.query();
$scope.countries = countriesResource.query();
$q.all([$scope.customer, $scope.titles, $scope.towns, $scope.colors, $scope.countries]).then(function(){
$scope.loading=false;
});
}]);
Although I am am hiding the actual admin screen until all of the ajax calls complete that is no guarantee that the DOM changes have completed (especially on older browsers). Also as I understand things every call into $http (used by ngResource) will cause a Root level digest to occur. Now I don't need all these digest calls and DOM updates until all the ajax requests have completed as I am hiding the screen until everything is loaded.
Is there a way I can suppress $digest from running and just have it run at the end of the controller init (where I am pretty sure it will do a $digest anyway).
Also is there a way I can get a callback to fire when the last of the DOM updates has succeeded or the $digest cycle has completed making DOM changes? As it stands at the moment even if I show a loading spinner whilst ajax requests are completing and do a ng-hide="loading" on my body element there is no way to guarantee that the DOM changes have completed. So I end up showing the content mid way through some DOM changes and I still get dropdowns which show as "select..." and then jump to the actual selected value once the DOM changes have proliferated.