【问题标题】:How to display ng2 -smart table row data in other page after click on the specific row单击特定行后如何在其他页面中显示 ng2 -smart table 行数据
【发布时间】:2021-10-17 21:24:58
【问题描述】:

我想在另一个页面上显示智能表行数据。因此,每当用户单击行数据时,它都会使用此特定行数据路由到新页面。

请帮忙,我卡住了

感谢This is mytable 高级

【问题讨论】:

    标签: angular ng2-smart-table


    【解决方案1】:

    查看 ng2-smart-table documentation,似乎有一个userRowSelect 事件,当用户单击一行时,该表会触发该事件。您可以处理它并使用Router 重定向到另一个页面。

    您可以使用 extras 传递行数据,如下所示:

    this.router.navigateByUrl('<path>', { state: data });
    

    您可以再次使用路由器访问处理路由的组件内部传递的数据

    const state = this.router.getCurrentNavigation()?.extras.state;
    

    但请注意router.getCurrentNavigation 方法只有在构造函数中调用时才会返回某些内容(或者更准确地说:在导航结束之前)。如果您需要访问构造函数之外的状态,则可以改用history.state(但这会为您传递的任何数据添加另一个属性,即navigationId)。

    【讨论】:

    • 感谢您的快速回复..您能给我发个例子吗?
    猜你喜欢
    • 2019-08-06
    • 1970-01-01
    • 1970-01-01
    • 2019-01-08
    • 2019-11-23
    • 2019-08-06
    • 2018-09-17
    • 2017-11-23
    • 1970-01-01
    相关资源
    最近更新 更多