Apply loading spinner during ui-router resolve

后端 未结 6 1224
面向向阳花
面向向阳花 2020-12-22 17:34

resolve property of $routeProvider allows to execute some jobs BEFORE corresponding view is rendered.

What if I want to display a spinner

6条回答
  •  抹茶落季
    2020-12-22 18:12

    To further Pranay's answer this is how I did it.

    JS:

    app.run(['$rootScope',function($rootScope){
    
        $rootScope.stateIsLoading = false;
        $rootScope.$on('$routeChangeStart', function() {
            $rootScope.stateIsLoading = true;
        });
        $rootScope.$on('$routeChangeSuccess', function() {
            $rootScope.stateIsLoading = false;
        });
        $rootScope.$on('$routeChangeError', function() {
            //catch error
        });
    
    }]);
    

    HTML

    Loading...

提交回复
热议问题