-
-
Notifications
You must be signed in to change notification settings - Fork 102
Router events
Murhaf Sousli edited this page Sep 10, 2024
·
16 revisions
Use the directive ngProgressRouter
to start and complete the progress bar with your router navigation.
Example:
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { NgProgressbar } from 'ngx-progressbar';
import { NgProgressRouter } from 'ngx-progressbar/router';
@Component({
standalone: true,
selector: 'app-root',
imports: [NgProgressbar, NgProgressRouter, RouterOutlet],
template: `
<ng-progress ngProgressRouter/>
<router-outlet/>
`
})
export class AppComponent {
}
import { GuardsCheckEnd, NavigationEnd } from '@angular/router';
import { provideNgProgressRouter } from '@ngx-progressbar/router';
bootstrapApplication(AppComponent, {
providers: [
provideNgProgressRouter({
startEvents: [GuardsCheckEnd],
completeEvents: [NavigationEnd],
minDuration: 1000
})
]
})
If Typescript complained about
startEvents
orcompleteEvents
values with red underlines, don't worry it will compile just fine. optionally, you can use type assertion e.g.completeEvents: [NavigationEnd] as Type<Event>[]
.
Name | Default | Description |
---|---|---|
minDuration | 0 | The minimum duration (in ms) the progress bar should run before completing. |
startEvents | [NavigationStart] | Router events that starts the progressbar. |
completeEvents | [NavigationEnd, NavigationCancel, NavigationError] | Router events that completes the 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