4

I have this function, when it's executed, it's fired 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" );
    } 

} 
Steffi
  • 6,835
  • 25
  • 78
  • 123
  • 1
    Where are your controllers? Where do you call this function from? If you call the controller twice it might fire twice – anvarik May 28 '14 at 07:44

1 Answers1

0

My routes changes twice because I wanted to reach url which doesn't exist, so finally to redirect me to /

Steffi
  • 6,835
  • 25
  • 78
  • 123