考虑到以下情况,是否可以从onvalueChanged主机侦听器中的模板访问“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
}
}发布于 2021-07-24 14:48:28
向您的指令添加一个输入,并从包含的模板传递单元格信息。
在指令中:
@Input() pimDxSelectBox: any;在包含组件中:
[pimDxSelectBox]="habitCellInfo"https://stackoverflow.com/questions/68507383
复制相似问题