L
L
Leopandro2018-11-14 13:59:40
Angular
Leopandro, 2018-11-14 13:59:40

How to hang an event handler on each NavigationEnd event in Angular?

Right now I'm handling each event like this:

ngOnInit() {
    this.router.events.subscribe((event: any) => {
      if (event.error) {
        this.router.navigate(['/login']);
      }
      if (event instanceof NavigationEnd) {
        console.log(event);
        console.log(this);
      }
    });

The question is how do I get the right response header?
This contains ActivatedRoute and Router, maybe you can do it somehow with the help of them?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question