Questions tagged [angular-router-events]

10 questions
7
votes
2 answers

how to find if page is reloaded/refreshed or navigated in Angular

I have to find whether a page is refreshed or it is loaded because of some routing. I think it's possible using Angular Router's NavigationEnd event by subscribeing to the router events. Anyone knows how to do it? No pure javascript solutions,…
Janier
  • 3,982
  • 9
  • 43
  • 96
6
votes
5 answers

Lazy Loaded Routing Problem after Upgrade to Angular 11

I have a top-level router that lazy loads child-routed feature modules, that has stopped working properly after upgrading to Angular v11.0.1. Logging out at the Router events in ng11, the feature module is loaded, and RouteConfigLoadStart and…
1
vote
1 answer

Angular display error banner after API error on all pages throughout the application

I have many components in angular and I am trying to display static error banner on all pages in case of GET API error related with that component. Through Interceptor I am able to get the API error but not sure how I can display banner throughout…
0
votes
1 answer

Cannot get RouterEvent to work in Angular 12

I want to monitor routing events in an angular app and maybe change the past during certain conditions. I wrote the following class: import {Event, RouterEvent, Router} from '@angular/router'; import {filter} from "rxjs"; @Injectable({ …
0
votes
0 answers

Prevent delay in Navigation in Angular

I have implemented lazyloading in my angular app and using loading indicator from navigation start to end. First time when app loads navigation is working fine with loading indicator and lazy loading is implemented. When click again the same module,…
0
votes
3 answers

Hide element if named router-outlet has active route

We are currently developing an Angular 13 application that is split into several independent modules that are maintained by different teams and each module represents the UI for a different application that is backed by its own microservice. These…
Simon
  • 148
  • 1
  • 14
0
votes
2 answers

Write unit test for "ActivationEnd" event from router.events.subscribe in angular

I need help in order to write unit tests for router.events.subscribe. I used ActivationEnd to use snapshot object which has properties which I need for my application. No other events from router provide these so I have to stick to this…
0
votes
1 answer

rxjs and angular router events: Set boolean to inital value after first emit

this function below should return true if an angular router event was triggered. private routeChanged$(): Observable { return this.router.events.pipe( filter(event => event instanceof NavigationEnd), mapTo(true), …
user4035841
0
votes
1 answer

Angular reloading component does not work

I am just trying to reload the component without refreshing the page. Here is the code for that: import { Component, VERSION, OnInit } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router' @Component({ selector:…
3gwebtrain
  • 14,640
  • 25
  • 121
  • 247
0
votes
1 answer

I am not able to inject Router in Angular component class

I am using fusion charts and my function requires redirection to a new page when a particular event is fired. I have successfully created the event handler. However router variable is not accessible from within the event handler. I have included…