Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 角度8在网格行操作的新窗口中布线到另一个组件,并传递整行_C#_.net_Angular_Typescript_Angular8 - Fatal编程技术网

C# 角度8在网格行操作的新窗口中布线到另一个组件,并传递整行

C# 角度8在网格行操作的新窗口中布线到另一个组件,并传递整行,c#,.net,angular,typescript,angular8,C#,.net,Angular,Typescript,Angular8,在“从网格选择操作”上,我想在“新建”选项卡中打开另一个组件。同时,我希望传递整行数据,以便在“新建”选项卡中打开另一个组件时加载数据 我尝试了以下几点: //redirects and load new component data correctly but opens in current tab instead of new tab navigate(row: ExampleRow){ this.router.navigate(['/new-page/1'], {state: {da

在“从网格选择操作”上,我想在“新建”选项卡中打开另一个组件。同时,我希望传递整行数据,以便在“新建”选项卡中打开另一个组件时加载数据

我尝试了以下几点:


//redirects and load new component data correctly but opens in current tab instead of new tab

navigate(row: ExampleRow){
this.router.navigate(['/new-page/1'], {state: {data: {row}}}); } 

//open new component in current window loaded with data but opens component with empty data in new tab as well
navigate(row: ExampleRow){
this.router.navigate([]).then(result => {  window.open('/new-page/1', '_blank'); }); }

// Throws error
<a [routerLink]="['/new-page', row.id]" [state]="{ data: row }" >Navigate</a> 



//正确重定向和加载新组件数据,但在当前选项卡而不是新选项卡中打开
导航(行:ExampleRow){
this.router.navigate(['/newpage/1'],{state:{data:{row}});}
//在加载了数据的当前窗口中打开新组件,但在“新建”选项卡中也打开了数据为空的组件
导航(行:ExampleRow){
this.router.navigate([])。然后(结果=>{window.open('/new page/1','_blank');})
//抛出错误
导航

当您打开一个新选项卡时,这两个网页是分开的,状态不会延续

navigate(row) {
  localStorage.setItem('data', JSON.stringify(row));
  window.open('/new-page/1', '_blank');
}
另一个组件

ngOnInit(): void {
  this.localTemp = JSON.parse(localStorage.getItem('data'));

  // here you can choose to keep it in the localStorage or remove it as shown below
  localStorage.removeItem('data');
}

谢谢你的及时回复。我的行中有敏感数据,因此存储在本地存储中是否安全?不,这不安全,如果您希望在两个窗口或选项卡之间进行通信,则可以实现某种服务器端通信。