简体   繁体   English

使用Angular 7的NavigateByUrl发送数据

[英]to send data with NavigateByUrl of Angular 7

I would like to know if it is possible to send data via navigateByUrl of Angular 7. I do not know if it is possible because I found little information about it. 我想知道是否可以通过Angular 7的navigationByUrl发送数据。我不知道是否可以,因为我发现的信息很少。 What I want to do is this: Send my selected client ID variable after clicking Enter in my TR(line of the table that is receiving focus). 我要执行的操作是:在TR(正在接收焦点的表的行)中单击Enter,然后发送我选择的客户端ID变量。 This through NavegateByUrl, is it possible? 通过NavegateByUrl可以吗?

My line: 我的台词:

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

My code: 我的代码:

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

My method is wrong, I know. 我知道我的方法是错误的。 But how is the correct way to send my variable through NavigateByUrl? 但是如何通过NavigateByUrl发送变量的正确方法呢?

Does anyone have any ideas for this? 有人对此有任何想法吗? If you have one, thank you in advance. 如果您有一个,请先谢谢。 If the question was not explicit, comment. 如果问题不明确,请发表评论。

You can use another option to pass data with URL. 您可以使用另一个选项来传递带有URL的数据。

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

For more info 欲了解更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 router.navigateByUrl不发送值Angular - router.navigateByUrl don't send value Angular Angular 中带有 navigateByUrl 的转发状态 - Forward state with navigateByUrl in Angular Angular Router:用false解析的navigationByUrl() - Angular Router: navigateByUrl() resolving with false 嘲笑 Angular navigateByUrl 仍在运行页面重新加载 - Mocked Angular navigateByUrl still running page reload Angular 路由器:从navigatebyurl 返回的promise 被忽略 - Angular router: promise returned from navigatebyurl is ignored Angular 的 .navigateByUrl() 导航到页面,但没有呈现 html - Angular's .navigateByUrl() navigates to the page but html is not rendered 使用 angular 中的 this.router.navigateByUrl 传递参数 Object - Pass parameters Object with this.router.navigateByUrl in angular 页面闲置后,Angular navigationByUrl具有巨大延迟 - Angular navigateByUrl with huge delay after page is idle Angular 6 Material - 无法读取未定义的属性“navigateByUrl” - Angular 6 Material - Cannot read property 'navigateByUrl' of undefined 如何强制 navigateByUrl() 在 Angular 9 中导航域根目录? - How to force navigateByUrl() to navigate the domain root in Angular 9?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM