Home Angularjs - stop loading application
Reply: 0

Angularjs - stop loading application

bluray
1#
bluray Published in 2018-01-12 20:08:10Z

I would like to ask how to stop loading application. I need this for showing modal window with login form. My idea is: User go to my webpage, first start LoginController which check if user is authenticated. If not, it displays the form but must be stopped loading next controllers and components (loading data by user id). Here is my concept:

    <body ng-controller="LoginController">
       controllers, components...
    </body>

app.controller("LoginController", function LoginController(){
  this.$onInit = function(){
     if(!authenticated()){
         showLoginModal();
         stopLoadingApp(); // what will be implementation?
     }
  }
})

I tried this, but not called:

app.controller("LoginController", function LoginController($rootScope){
$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
                event.preventDefault(); //not called
        });
});

Please help me how to solve this problem. Thanks

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.340284 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO