In one of my Angular 2 routes\'s templates (FirstComponent) I have a button
first.component.html
It is 2019 and many of the answers here would work, depending on what you want to do. If you want to pass in some internal state not visible in URL (params, query) you can use state since 7.2 (as I have learned just today :) ).
From the blog (credits Tomasz Kula) - you navigate to route....
...from ts: this.router.navigateByUrl('/details', { state: { hello: 'world' } });
...from HTML template: Go
And to pick it up in the target component:
constructor(public activatedRoute: ActivatedRoute) {}
ngOnInit() {
this.state$ = this.activatedRoute.paramMap
.pipe(map(() => window.history.state))
}
Late, but hope this helps someone with recent Angular.