import....
export class AppComponent {
constructor(private injector: Injector) {
const ourDynamicDiv = document.getElementById('anynewdiv');
const tooltip: MatTooltip = Injector.create({
parent: this.injector,
providers: [
{
provide: ElementRef,
useValue: new ElementRef(ourDynamicDiv)
},
{
provide: MatTooltip,
useClass: MatTooltip,
deps: [
Overlay,
ElementRef,
ScrollDispatcher,
ViewContainerRef,
NgZone,
Platform,
AriaDescriber,
FocusMonitor,
MAT_TOOLTIP_SCROLL_STRATEGY,
Directionality,
MAT_TOOLTIP_DEFAULT_OPTIONS,
// HAMMER_LOADER
]
}
]
}).get(MatTooltip);
tooltip.position = 'above';
tooltip.message = `message text`;
}
Прикрепляет всплывающую подсказку к динамически добавляемому элементу.