错误TypeError:无法读取未定义角度的属性“标签”

时间:2019-12-22 20:42:43

标签: angular typescript rxjs

MemberDetailedComponet

@ViewChild('memberTabs', { static: false }) memberTabs: TabsetComponent;
ngOnInit() {
    /* get thr routes tab parameter */
    this.route.queryParams.subscribe(params => {
      // tslint:disable-next-line: no-string-literal
      const selectTab = +params['tab'];
      console.log('queryparams:' + selectTab);
      this.memberTabs.tabs[selectTab > 0 ? selectTab : 0].active = true;
    });
}
selectTab(tabId: number) {
    this.memberTabs.tabs[tabId].active = true;
  }

在routerlink中

[routerLink]="['/members']"[queryParams]="{ tab: 3 }"

尽管selectTab读取该值,但在控制台中显示未定义的标签

1 个答案:

答案 0 :(得分:0)

{ static: false} 替换为 { static: true }