如何使用角片段将数据从一个页面传递到另一页



我试图在导航到另一个页面时发送另一个页面。

this.router.navigateByUrl('/homePage', { fragment:"hello world"});

我不确定如何在主页中收到片段。我在主页上在下面尝试了他的内容。

ngOnInit() {
    this.router.fragment.subscribe((fragment: any) => {
      console.log("My hash fragment is here => ", fragment)
    })
}

我越来越不确定,我不确定如何收到片段任何帮助...

我能够通过更改以下

在主页中打印console.log
this.router.navigateByUrl('/homePage', { fragment:"hello world"});

到这个

this.router.navigate(['parameter-to-device'], { fragment:"hello world"});

相关内容

最新更新