You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A projected template is subject to a ChangeDetectionRef which is not controlling the template #14321
Current behavior
When projecting a template into another component as a ContentChild, the template is subjected to the ChangeDetectorRef of the host component and not of the component in which the template is defined. This results in a situation in which a projected component is not notified of changes.
Expected behavior
A template needs to be independent of the changeDetectionRef in which the template is projected, because there is no direct relation between the two components.
This plunkr reproduces the problem. A template containing a ProjectedComponent is projected into the TestComponent. All of this is defined in the TestApp Component. The ProjectedComponent has an @Input which can be changed by editing the input element. However, due to the OnPush changedetection stategy of the TestComponent, the value is not updated in the ProjectedComponent.
It seems that the projected content is subject to the wrong ChangeDetectionStrategy making it impossible to project rich content into another component without (somehow) exposing the changedetection strategy of the host component.
What is the motivation / use case for changing the behavior?
Please tell us about your environment:
Just a browser (JIT)
Angular version: 2.X
Browser: all
Language: Typescript
Reacted by Sebastiaan de Rooij, kzubreck and Simon Weaver
When projecting a template into another component as a ContentChild, the template is subjected to the ChangeDetectorRef of the host component and not of the component in which the template is defined
sounds reasonable to me. @mhevery what do you think?
Activity
Hikariii commentedon Feb 21, 2017
Pinging to see if anyone can verify / label this issue
DzmitryShylovich commentedon Feb 21, 2017
sounds reasonable to me. @mhevery what do you think?
tbosch commentedon Apr 10, 2017
Agree, we should change this.
tbosch commentedon May 3, 2017
Needed for G3 as well!
fix(core): projected views should be dirty checked when the declaring…
fix(core): projected views should be dirty checked when the declaring…
fix(core): projected views should be dirty checked when the declaring…
fix(core): projected views should be dirty checked when the declaring…
fix(core): projected views should be dirty checked when the declaring…
fix(core): projected views should be dirty checked when the declaring…
robeverett commentedon Sep 25, 2018
I'm suffering from this in Angular 6.
What is the solution ?
Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ngIf: '. Current value: 'ngIf: undefined'.
AppComponent.html:10
ERROR CONTEXT
AppComponent.html:10
DebugContext_ {view: Object, nodeIndex: 10, nodeDef: Object, elDef: Object, elView: Object}
angular-automatic-lock-bot commentedon Sep 14, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
fix(core): projected views should be dirty checked when the declaring…