使用Angular 7的NavigateByUrl发送数据

时间:2019-04-10 12:59:36

标签: angular

我想知道是否可以通过Angular 7的navigationByUrl发送数据。我不知道是否可能,因为我发现的信息很少。我要执行的操作是:在TR(正在接收焦点的表的行)中单击Enter,然后发送我选择的客户端ID变量。通过NavegateByUrl可以做到吗?

我的电话:

    <tr (keyup.enter)="customerSelected(selectedCustomer)">

我的代码:

   customerSelected(customer_id){
     this.selectedCustomer = customer_id;    
     this.router.navigateByUrl('cadastro/selectedCustomer'); //to send variable, how?
   }

我知道我的方法是错误的。但是如何通过NavigateByUrl发送变量的正确方法呢?

有人对此有任何想法吗?如果您有一个,请先谢谢。如果问题不明确,请发表评论。

1 个答案:

答案 0 :(得分:1)

您可以使用另一个选项来传递带有URL的数据。

this.router.navigate(['cadastro/selectedCustomer'] , {queryParams:{title:'Dashboard' , flag:true}})

更多info