Skip to content

Instantly share code, notes, and snippets.

@realtomaszkula
Last active January 13, 2019 13:40
Show Gist options
  • Save realtomaszkula/af0ffd9fa98a8203ed81d8f8c316de21 to your computer and use it in GitHub Desktop.
Save realtomaszkula/af0ffd9fa98a8203ed81d8f8c316de21 to your computer and use it in GitHub Desktop.
@Component({
selector: 'app-root',
template: `<pre>{{ state$ | async | json }}</pre>`,
})
export class AppComponent implements OnInit {
private state$: Observable<object>;
constructor(public router: Router) { }
ngOnInit() {
this.state$ = this.router.events.pipe(
filter(e => e instanceof NavigationStart),
map(() => this.router.getCurrentNavigation().extras.state)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment