Skip to content

Instantly share code, notes, and snippets.

@rakia
Created May 22, 2024 20:47
Show Gist options
  • Save rakia/d3ffcd686bd43d5ec11575d0c519e810 to your computer and use it in GitHub Desktop.
Save rakia/d3ffcd686bd43d5ec11575d0c519e810 to your computer and use it in GitHub Desktop.
Angular Routing: RedirectCommand
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