Skip to content

Commit

Permalink
feat(docs): deleting routing to button/overview by default (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
Margar1ta authored and pimenovoleg committed Sep 6, 2019
1 parent 97183b0 commit a70086c
Showing 1 changed file with 12 additions and 8 deletions.
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');
}

}

0 comments on commit a70086c

Please sign in to comment.