Angular 9 - How to force re-render of component from within directive?

254 Views Asked by At

So I tried to implement inplace-edit on any input using attribute directive in angular 9 (using Ivy if that matters). https://stackblitz.com/edit/angular-inline-edit-qwb2bg?file=src/app/inplace-edit/inplace-edit.directive.ts

The idea is that I can take any component and change appearance from directive. The problem is that I don't know how to revert to original intact appearance :-) So when I click on text - that text should be changed to simple input. Tried so many approaches - nothing worked for me.

Well, there is a working approach with wrapping component into some other component and using ngIf with ngTemplateOutlet, but I want some cleaner solution - smth like in old good jQuery editinplace pluging - just to change behaviour and appearance of any component...

So in general the question is: if attribute directives can be used to alter appearance and behaviour of component, what should be done to fire re-render of component so it will appear as if no directive was applied to it?..

0

There are 0 best solutions below