(Angular-ui-router) Show loading animation during resolve process

后端 未结 11 845
生来不讨喜
生来不讨喜 2020-12-07 07:12

This is a two part question:

  1. I am using the resolve property inside $stateProvider.state() to grab certain server data before loading the controller. How wo

11条回答
  •  甜味超标
    2020-12-07 08:09

    This is loader for globally when page navigate between any state (any page), put in app.js

    .run(
        ['$rootScope',
            function($rootScope) {
                $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
                    $rootScope.preloader = true;
                })
                $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
                    $rootScope.preloader = false;
                })
            }
        ])
    

    In html:

    Loading...

提交回复
热议问题