How to redirect on different view on refresh in AngularJS?

前端 未结 1 1499
情话喂你
情话喂你 2021-01-12 12:28

i\'m developing an application in AngularJS. Basically, i have a \"home\" page and a \"new project\". In the home page i have a menu with a link to \"new project\".

相关标签:
1条回答
  • 2021-01-12 12:54

    Use this in your controller of 'newproject' it is listening your refresh:

    $rootScope.$on('$locationChangeStart', function(event) {
         $state.go('home');
    });
    

    or put this in app.run();

    $rootScope.$on("$locationChangeStart", function(event, next, current) { 
    
        if(next==current && next=='/newproject')
            $state.go('home');
    
    });
    
    0 讨论(0)
提交回复
热议问题