我正在使用Wijmo的wjFlexGridDetail
指令,并希望根据组件中的“detailData”数组是否包含任何匹配数据来控制哪些行显示详细网格。 rowHasDetail
属性使用外部网格的行作为输入并返回布尔值的函数。我想要做这样的事情:将任意数据传递给子指令
<ng-template wjFlexGridDetail let-item="item" [rowHasDetail]="hasDetail">
hasDetail (row): boolean {
return this.detailData.filter(item => item.ID === row.dataItem.ID).length > 0
} // detailData is undefined when I try this
但是,这并不工作,因为this
在函数的范围是指wjFlexGridDetail
对象,其中不包含我想核对数据。我试着结合它作为数据属性:
<ng-template wjFlexGridDetail let-item="item" [rowHasDetail]="hasDetail" [attr.data-detail]="detailData">
,但得到了一个错误:
Uncaught (in promise): Error: Template parse errors: Property binding data-detail not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations".
有另一种方式来获得这些数据到函数的范围是什么?或者专门用于wjFlexGridDetail
的用法,是否有另一种方法来实现我的目标(我希望它只显示具有详细数据的行的+扩展按钮)?