ngProgress icon indicating copy to clipboard operation
ngProgress copied to clipboard

$scope.$apply from ngProgress.color is interfering with $templateCache service, when called from angular.module().run method

Open chris-equis opened this issue 11 years ago • 3 comments

Here's a sample of run() method

angular
    .module('portal', dependencies)
    .run(['$rootScope', '$http', 'ngProgress', 'NotifyService', function($rootScope, $http, ngProgress, Notify) {
        ngProgress.color('#66afda');
        $rootScope.pendingRequests = $http.pendingRequests;
        $rootScope.$watch('pendingRequests', function(requests) {
            ngProgress[requests.length !== 0 ? 'start' : 'complete']();
        }, true);

        $rootScope.$on('$routeChangeError', function() { Notify.error('An error occured when trying to change the current route!'); })

    }]);

and here's a sample of routes configuration

$routeProvider
    .when('/application-:appId', {})
    .when('/application-:appId/:portalViewId/:viewType-:viewId', {
        controller: 'PortalViewCtrl',
        reloadOnSearch: false,
        templateUrl: function($routeParams) {
            var viewType = $routeParams.viewType;
            return (viewType && portalViewTypes.indexOf(viewType) > -1) && 'portal/portal-views/' + viewType + '/' + viewType + '-view.html';
        }
    })

    .otherwise({redirectTo: '/'});

We're using ngTemplates Grunt plugin to check get all the templates and put them into $templateCache service.

Please note that all the template are included, the paths are correct within this service, everything works ok either by removing the ngProgress.color('#66afda'); line, or commenting out the line where the scope is manually applied (from ngProgress code).

chris-equis avatar Sep 26 '14 11:09 chris-equis

Hey, thanks for reporting the issue!

Is it possible for you to setup a demo plnkr.co where the issue is happening to make it a bit easier to debug?

Thanks.

victorb avatar Sep 26 '14 14:09 victorb

Getting the same issue in pretty much the same conditions.

I've traced the cause to inside the color method, to the $scope.$$phase and $scope.$apply calls. But after working on it for a good amount of time, we decided to just !important the background-color from CSS.

tvararu avatar Feb 11 '15 17:02 tvararu

Getting exactly the same issue, will use the !important ><.

KannarFr avatar Apr 28 '16 10:04 KannarFr