Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular2 $routeChangeStart , $routeChangeSuccess ,$routeChangeError

Tags:

angular

In angular2 what is the equivalent of these angular1 events?

$routeChangeStart , $routeChangeSuccess ,$routeChangeError

I want to use these events in root app component to deal with any route changing.

thanks in advance

update

  • If i use OnActivate, OnDeactivate events, it needs to add it to every component :(

  • Also i tried to implement my own RouterOutlet but i can't access previous instruction on activate, deactivate events, also i don't know how to handle the route Change Error

  • Also router.subscribe gave me the name only but i want to get the current and next instruction objects to change some properties

My target is:

1- Show loading indicator when start change page and hide it on page load.

2- Make transition animation rtl or ltr for current and next instruction

like image 532
Bahgat Mashaly Avatar asked Nov 05 '15 10:11

Bahgat Mashaly


1 Answers

There are some events such as OnActivate, OnDeactivate and guard functions CanActivate and CanDeactivate that you can look at.

See the documentation for Router

like image 142
Chandermani Avatar answered Sep 29 '22 13:09

Chandermani