search

Home  >  Q&A  >  body text

angular.js - What does angular ui-router "deferIntercept" do and how should it be applied?

"deferIntercept"

I feel that this thing is helpful to me, but the documentation is not very thorough.

Do you have a simpler introduction or demo? Thank you

为情所困为情所困2856 days ago620

reply all(1)I'll reply

  • 黄舟

    黄舟2017-05-15 17:06:31

    The following is the normal writing method. . .

    App.config(function ($stateProvider, $urlRouterProvider) {
        // $urlRouterProvider.deferIntercept();
    
        $urlRouterProvider.otherwise('/view/index');
        $stateProvider
                .state('Home', {
                    url: '/view/index',
                    templateUrl: 'view/index.html'
                })
                .state('Error', {
                    url: '/view/error',
                    templateUrl: 'view/error.html'
                })
    });

    If you add $urlRouterProvider.deferIntercept(), both the default route and the redirected route will be disabled. This is why the official website says to prevent URL jumps~

    reply
    0
  • Cancelreply