【发布时间】:2020-01-29 15:17:29
【问题描述】:
这是正在使用的自定义指令,
constructor(
private el: ElementRef,
private renderer: Renderer
) { }
@HostListener('mouseover') onHover() {
const offWidth = this.el.nativeElement.offsetWidth;
const scrollWidth = this.el.nativeElement.scrollWidth;
if(offWidth < scrollWidth) {
this.renderer.setElementAttribute(this.el.nativeElement, 'matTooltipDisabled', false);
console.log("enable tooltip");
} else {
this.renderer.setElementAttribute(this.el.nativeElement, 'matTooltipDisabled', true);
console.log("disable tooltip");
}
}
这不起作用。垫子工具提示始终启用。属性正确更新为 true 和 false,但始终显示工具提示。
<input
appMyCustomDirective
class="testclass"
name="testval"
id="testid"
[(ngModel)]="testval"
type="text"
autocomplete="off"
[matTooltip] = "testval"
matTooltipClass = "tooltip"
matTooltipPosition = "above"
/>
【问题讨论】: