Minimal error version reproduction: https://stackblitz.com/edit/angular-zlh4ri
explanation:
- a component(comp1) use
<ng-container><span #viewEl></span></ng-container>
; - another component(comp2) use
<span #viewEl></span>
; - a commom directive try to access the
#viewEl
in 1/2 component; - comp1 raize a error:
NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: '[object Object]'. Current value: 'undefined'
How should I fix it?
(Allow change structure, but note that the directive should keep a copy of viewEl
because I need it