-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs): deleting routing to button/overview by default (#235)
- Loading branch information
1 parent
fc04ceb
commit c017353
Showing
1 changed file
with
12 additions
and
8 deletions.
There are no files selected for viewing
20 changes: 12 additions & 8 deletions
20
packages/docs/src/app/components/main-layout/main-layout.component.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,33 @@ | ||
import { Component } from '@angular/core'; | ||
import { ActivatedRoute, Router } from '@angular/router'; | ||
import {ActivatedRoute, NavigationExtras, Router} from '@angular/router'; | ||
|
||
|
||
@Component({ | ||
templateUrl: './main-layout.component.html', | ||
styleUrls: ['./main-layout.component.scss'] | ||
}) | ||
export class MainLayoutComponent { | ||
nextRoute: string = ''; | ||
extras: NavigationExtras = { | ||
preserveFragment: true, | ||
queryParamsHandling: 'preserve' | ||
}; | ||
|
||
constructor(private router: Router, | ||
private route: ActivatedRoute) { | ||
|
||
this.setNextRoute(); | ||
|
||
if (this.router.routerState.snapshot.url === '/') { | ||
this.router.navigateByUrl('button/overview'); | ||
} | ||
} | ||
|
||
setNextRoute() { | ||
const nextRoute = localStorage.getItem('PT_nextRoute'); | ||
this.nextRoute = localStorage.getItem('PT_nextRoute'); | ||
|
||
if (nextRoute) { | ||
this.router.navigate([nextRoute], { preserveFragment: true, queryParamsHandling: 'preserve' }); | ||
if (this.nextRoute) { | ||
this.router.navigate([this.nextRoute], this.extras); | ||
} else { | ||
this.router.navigate(['button/overview'], this.extras); | ||
} | ||
localStorage.removeItem('PT_nextRoute'); | ||
} | ||
|
||
} |