Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
chris-equis opened this issue Sep 26, 2014 · 3 comments

Comments

@chris-equis
Copy link

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).

@victorb
Copy link
Owner

victorb commented Sep 26, 2014

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.

@tvararu
Copy link

tvararu commented Feb 11, 2015

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.

@KannarFr
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants