Skip to content

Commit 7928ff1

Browse files
portneonthePunderWoman
authored andcommitted
docs(router): update navigation event example to use event.code
(cherry picked from commit 93d548f)
1 parent 7020ef6 commit 7928ff1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

adev/src/content/guide/routing/lifecycle-and-events.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ Handle navigation errors gracefully and provide user feedback:
151151
```angular-ts
152152
import { Component, inject, signal } from '@angular/core';
153153
import { Router, NavigationStart, NavigationError, NavigationCancel, NavigationCancellationCode } from '@angular/router';
154+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
154155
155156
@Component({
156157
selector: 'app-error-handler',
@@ -176,7 +177,7 @@ export class ErrorHandlerComponent {
176177
this.errorMessage.set('Failed to load page. Please try again.');
177178
} else if (event instanceof NavigationCancel) {
178179
console.warn('Navigation cancelled:', event.reason);
179-
if (event.reason === NavigationCancellationCode.GuardRejected) {
180+
if (event.code === NavigationCancellationCode.GuardRejected) {
180181
this.errorMessage.set('Access denied. Please check your permissions.');
181182
}
182183
}

0 commit comments

Comments
 (0)