Created
May 22, 2024 20:47
-
-
Save rakia/d3ffcd686bd43d5ec11575d0c519e810 to your computer and use it in GitHub Desktop.
Angular Routing: RedirectCommand
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const routes: Routes = [ | |
{ | |
path: 'dashboard', | |
component: DashboardComponent, | |
canActivate: [ | |
() => { | |
const router: Router = inject(Router); | |
const urlTree: UrlTree = router.parseUrl('/error'); | |
return new RedirectCommand(urlTree, { skipLocationChange: true }); | |
}, | |
], | |
}, | |
{ | |
path: 'error', | |
component: ErrorComponent, | |
}, | |
{ | |
path: 'profile', | |
component: ProfileComponent, | |
resolve: { | |
redirectMe: () => { | |
return new RedirectCommand(inject(Router).parseUrl('/signin')); | |
}, | |
}, | |
}, | |
{ | |
path: 'signin', | |
component: SignInComponent, | |
}, | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment