1

如下所示,我可以将多个局部变量引用到同一个元素吗?#datatable #selectionTable

基本上,我面临的问题是,我能够DatatableComponent使用@viewChild.

但是我无法通过导入来访问另一个子组件@viewChild。当我尝试控制台并查看我新导入的组件时,我DatatableComponent只获取了详细信息而不是DataTableSelectionComponent详细信息。

import { DataTableSelectionComponent } from '@swimlane/ngx-datatable/release/components/body/selection.component';
import { DatatableComponent } from '@swimlane/ngx-datatable/release/components/datatable.component';


@ViewChild('selectionTable') selectionComponent: DataTableSelectionComponent;
@ViewChild('datatable') datatableComponent: DatatableComponent;

<ngx-datatable #datatable #selectionTable class="striped" 
   [ngStyle]="_datatableHeight" [headerHeight]="datatableHeaderHeight"
   [selectionType]="'checkbox'" [rows]="_rows" [columns]="_columns" 
   [rowHeight]="rowHeight" [cssClasses]="cssClasses"
   [columnMode]="columnMode" (select)="onSelect($event)" 
   (activate)="activateRow($event)" [trackByProp]="'name'"
   [scrollbarV]="isScroll">

  <ngx-datatable-row-detail *ngIf='detailRow && detailRow.template' 
     [rowHeight]="detailRow.height" [template]="detailRow.template">
  </ngx-datatable-row-detail>

</ngx-datatable>
4

0 回答 0