Вот основная структура, которую я хочу:
Код: Выделить всё
I programmatically add a tooltip to my distant ancestor on hover
I am programmatically rendered and destroyed
Первое допускает это, но у него есть другая проблема: когда я уничтожаю подсказку, используя это.tooltipinstance.destroy () , он также удаляет элемент хоста.
Код: Выделить всё
I programmatically add a tooltip to my distant ancestor on hover
I am programmatically rendered and destroyed
< /code>
eventMouseEnter({ event, el }) {
this.tooltipInstance = createComponent(TooltipComponent, {
environmentInjector: this.injector,
hostElement: document.querySelector('.event-tooltip-host')!,
bindings: [inputBinding('event', () => event), inputBinding('element', () => el)]
})
this.appRef.attachView(this.tooltipInstance.hostView)
this.tooltipInstance.changeDetectorRef.detectChanges()
}
eventMouseLeave() {
this.appRef.detachView(this.tooltipInstance.hostView)
this.tooltipInstance.destroy()
}
< /code>
It appears impossible to fully control dynamic rendering of a component back and forth from within a totally random component.
My backup plan is to do it from Dashboard component via some app-level actions which I can listen to in any component, but I would really expect Angular to have a better way to do it.
So, the question is [b]how do I avoid destroying the wrapper,[/b] ?
Подробнее здесь: https://stackoverflow.com/questions/796 ... nt-angular
Мобильная версия