我ActivatedRoute
用来将汇总表从一个组件调用到另一个组件,我在下面添加了我无法在点击事件中按预期获取汇总表
选项卡路由.module.ts
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { TABMasterComponent } from '../tabs/tab-master/tab-master.component';
const routes: Routes = [
{ path: "tabmasters", component: TABMasterComponent,
loadChildren:'../tabs/tab-master/tab-master.component',
data:{
istab : false
}
},
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
tabmasters.component.ts
istab = false;
constructor(private fb: FormBuilder,private router: Router, private toastr:ToastrService, private route:ActivatedRoute) {
this.istab = this.route.snapshot.data.istab;
console.log('here',this.route.snapshot.data)
}
tabmaster.component.html
<div *ngIf="iscontrol">
<div class="table-responsive">
<table class="table">
<thead class="table_header">
<tr>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let cl of ClList;">
<td>{{ cl.name}}</td>
</tr>
</tbody>
</table>
</div>
</div>
<div *ngIf="istab">
<div class="table-responsive">
<table class="table">
<thead class="table_header">
<tr>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let tab of tabList;">
<td>{{ tab.name}}</td>
</tr>
</tbody>
</table>
</div>
</div>
当我在应用程序组件中使用 click 事件时,我想显示 istab 摘要。但我面临的问题是上面的这两个表在选项卡组件中,我只想在点击事件中显示 istab 摘要
TAB1----isctrl summary TAB2-----istab summary
我使用了boolean
if I click tab 1
isctrl
true
and istab
false
if I click tab2
ista
is true
and isctrl
isfalse
以上两个摘要tabcomponent
用于显示引导导航选项卡,如下面的选项卡
我的app.component.HTML就像
<button (click)="gotoTabsUMMARY()"></button>
我的app.component.TS就像
istab = false;
constructor(private fb: FormBuilder,private router: Router, private toastr:ToastrService, private route:ActivatedRoute) {
this.istab = this.route.snapshot.data.istab;
console.log('here',this.route.snapshot.data)
}
gotoTabsUMMARY(){
this.router.navigate(["/tabsmasters"], { skipLocationChange: true, this.istab})
}
我想在应用组件的点击事件中转到汇总表。正常的路由器链接正在工作,但我想获得 tab2 中的摘要,我使用了另一种方法,emit 不起作用如何使用activatedRoute
这个..