给定以下内容,是否可以从onvaluechange主机侦听器中的模板访问'habitCellInfo' ?
<div *dxTemplate="let habitCellInfo of 'habitEditCellTemplate'">
<dx-select-box
(onValueChanged)="
onHabitEditorValueChanged($event, habitCellInfo)
"
[dataSource]="habitsDataSrc"
[value]="habitCellInfo.data.habit"
pimDxSelectBox
>
<dx-validator>
<dxi-validation-rule
pimDxiValidationRule
rule="noun"
></dxi-validation-rule>
</dx-validator>
</dx-select-box>
</div>
import { DxSelectBoxComponent } from 'devextreme-angular';
import DataSource from 'devextreme/data/data_source';
import {
Directive, ElementRef, HostListener, Input, NgModule, OnInit, Renderer2, Self
} from '@angular/core';
import { addSelectBoxCustomItem } from '@pim/common/shared-dx/util';
import { PimDxModules } from '../modules/pim-dx-modules.module';
@Directive({
selector: '[pimDxSelectBox]',
})
export class PimDxSelectBoxDirective implements OnInit {
@Input() acceptCustomValue = true
@Input() dataSource!: DataSource
// Inject an instance of select-box
constructor(
private elRef: ElementRef,
@Self() private readonly selectBox: DxSelectBoxComponent,
private renderer: Renderer2,
) {}
ngOnInit(): void {
this.selectBox.acceptCustomValue = this.acceptCustomValue
this.selectBox.dataSource = this.dataSource
this.selectBox.grouped = this.grouped
}
@HostListener('onValueChanged', ['$event'])
editorValueChanged(e: Event) {
// HOW DO I
}
}
在指令中添加一个输入,并从包含它的模板中传递单元格信息。
在指令中:
@Input() pimDxSelectBox: any;
在包含组件中:
[pimDxSelectBox]="habitCellInfo"