【问题标题】:How to pass data from one page to another page using angular fragments?如何使用角度片段将数据从一页传递到另一页?
【发布时间】:2019-05-07 17:10:06
【问题描述】:

我正在尝试在导航到另一个页面时将数据发送到另一个页面。

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

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

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

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

【问题讨论】:

    标签: angular ionic4 angular7-router


    【解决方案1】:

    我可以通过更改以下内容在我的主页中打印 console.log

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

    到这里

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-19
      • 1970-01-01
      • 2018-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多