-
-
Notifications
You must be signed in to change notification settings - Fork 102
Router events
Murhaf Sousli edited this page Aug 12, 2024
·
16 revisions
Use this plugin to start and complete the progress bar with your router navigation.
import { NgProgressRouterModule } from 'ngx-progressbar/router';
bootstrapApplication(AppComponent, {
providers: [
importProvidersFrom(NgProgressRouterModule)
]
})
And just add the progress bar component in your template
<ng-progress/>
Use NgProgressRouterModule.withConfig({...})
to set the following config
NgProgressRouterConfig API
Name | Default | Description |
---|---|---|
id | root | Progress bar ID. |
delay | 0 | The delay before completing the progress bar in ms. |
startEvents | [NavigationStart] | Router events that starts the progressbar. |
completeEvents | [NavigationEnd, NavigationCancel, NavigationError] | Router events that completes the progressbar. |
import { RouterModule, GuardsCheckEnd, NavigationEnd } from '@angular/router';
import { NgProgressRouterModule } from '@ngx-progressbar/router';
bootstrapApplication(AppComponent, {
providers: [
importProvidersFrom(
NgProgressHttpModule.withConfig({
startEvents: [GuardsCheckEnd],
completeEvents: [NavigationEnd],
delay: 1000,
id: 'router-progressbar'
})
)
]
})
Or
import { RouterModule, GuardsCheckEnd, NavigationEnd } from '@angular/router';
import { NgProgressRouterModule, NG_PROGRESS_ROUTER_CONFIG } from '@ngx-progressbar/router';
bootstrapApplication(AppComponent, {
providers: [
importProvidersFrom(NgProgressHttpModule),
{
provide: NG_PROGRESS_ROUTER_CONFIG,
useValue: {
startEvents: [GuardsCheckEnd],
completeEvents: [NavigationEnd],
delay: 1000,
id: 'router-progressbar'
}
}
]
})
A list of available router events can be found https://angular.dev/guide/routing/router-reference#router-events
Become a sponsor and get your logo on our README on GitHub and the front page of https://ngx-progressbar.netlify.com/.
Become a backer and get your logo on our README on GitHub.
Older version (v12)
-
Automagic features
Older version (v11)
-
Automagic features