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
[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
If a directive injects a ChangeDetectorRef it receives the parent element's instance rather than the one on the host element.
I'm not sure if this is intentional, but it seems like there should be a way for the directive to use the host element's ChangeDetectorRef.
Expected behavior
A directive should be able to inject the host element's ChangeDetectorRef
Minimal reproduction of the problem with instructions
I created a directive called RenderOnce that detaches the change detector in ngAfterViewInit.
I have two elements that increment a number on an interval, one of them I add the directive, the other one I don't. But the directive detaches the parent component's change detector so they both only render once.
Reacted by Suguru Inatomi, Zhoucheng Li, Daniel Falabella, Hugo Campos, Jason K. and Simon Weaver
@DzmitryShylovich that is right, never mind. Here the use case was a directive to integrate with MobX (https://github.com/mobxjs/mobx-angular) and in that case it is actually acceptable to get the parent's change detector, hence why I thought it had been fixed.
Activity
dfala commentedon Nov 23, 2016
Any updates on fixing this bug? This is a UGE issue for me.
hccampos commentedon Mar 7, 2017
@dfala seems like this is fixed in rc.2
DzmitryShylovich commentedon Mar 7, 2017
@hccampos don't think so http://plnkr.co/edit/Aqjpv3KDrDJbnI43YdzC?p=preview
hccampos commentedon Mar 7, 2017
@DzmitryShylovich that is right, never mind. Here the use case was a directive to integrate with MobX (https://github.com/mobxjs/mobx-angular) and in that case it is actually acceptable to get the parent's change detector, hence why I thought it had been fixed.
tbosch commentedon Apr 11, 2017
This also happens when using
Injector.get(ChangeDetectorRef), see #14656fix(core): allow directives to inject the component’s `ChangeDetector…
fix(core): allow directives to inject the component’s `ChangeDetector…
fix(core): allow directives to inject the component’s `ChangeDetector…
angular-automatic-lock-bot commentedon Sep 11, 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.