From c017353447b20881e220f2c25066122113cec1ed Mon Sep 17 00:00:00 2001 From: Iakovleva Margarita Date: Fri, 6 Sep 2019 20:16:50 +0300 Subject: [PATCH] feat(docs): deleting routing to button/overview by default (#235) --- .../main-layout/main-layout.component.ts | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/docs/src/app/components/main-layout/main-layout.component.ts b/packages/docs/src/app/components/main-layout/main-layout.component.ts index 79095f609..a606a14d0 100644 --- a/packages/docs/src/app/components/main-layout/main-layout.component.ts +++ b/packages/docs/src/app/components/main-layout/main-layout.component.ts @@ -1,5 +1,5 @@ import { Component } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; +import {ActivatedRoute, NavigationExtras, Router} from '@angular/router'; @Component({ @@ -7,23 +7,27 @@ import { ActivatedRoute, Router } from '@angular/router'; 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'); } }