Why does $ routeChangeStart fire twice in AngularJS?

I have this function, when it is executed, it runs twice. I see alert(ok), then alert(ok)I don’t know why.

$rootScope.$on( "$routeChangeStart", function(event, next, current) {

    if ( next.templateUrl == "partials/login.html" ) {
       alert( "ok" );
       $location.path( "/login" );
    } 

} 
+4
source share
1 answer

My routes change twice because I wanted to reach a URL that is not there, therefore, to redirect me to /

0
source

Source: https://habr.com/ru/post/1542200/


All Articles