【发布时间】:2020-07-10 15:56:53
【问题描述】:
我正在制定一个指令,以确保剑道组合框在获得焦点时会打开其菜单。 这是我到目前为止得到的:
import { Directive, ElementRef, HostListener } from '@angular/core';
import { ComboBoxComponent } from '@progress/kendo-angular-dropdowns'
@Directive({
selector: 'kendo-combobox[openOnFocus]'
})
export class OpenOnFocusDirective {
private combobox: ComboBoxComponent;
constructor(el: ElementRef) {
this.combobox = el.nativeElement as ComboBoxComponent;
}
@HostListener('focus') onFocus() {
this.combobox.toggle(true);
}
@HostListener('blur') onBlur() {
this.combobox.toggle(false);
}
}
html:
<kendo-combobox openOnFocus ...>
</kendo-combobox>
但是“切换”命令没有做任何事情。 阅读文档告诉我它应该打开(或关闭)下拉列表。
https://www.telerik.com/kendo-angular-ui/components/dropdowns/api/ComboBoxComponent/
任何帮助将不胜感激!
【问题讨论】:
-
你试过@ViewChild吗?
标签: angular combobox kendo-ui directive