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
ngOutletContext causes template to re-initialize on data changes #13407
[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
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
Nested component should have the ability to control when they redraw, rather than it being forced simply by the use of . In my case, I would like to redraw charts with a transition.
Please tell us about your environment:
Angular version: 2.0.X
2.0.0
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
We could change implementation of the ngTemplateOutlet although it would be a bit tricky. before doing so I will dig into part of the view / CD engine that re-creates object literals.
I think the root problem for ngTemplateOutlet is ViewContainerRef.context to be readonly so we can't change a context but just create it once and then mutate it.
When @DzmitryShylovich tried to fix that issue this was his main issue, if user provides a new context we can't just replace it but we would have to run a differ and mutate the actual context to shape it exactly like the new context being passed.
I find it weird for Angular to enforce mutation of data here when it's more about immutable data everywhere else.
So I think there should be a way to change the context (the reference), maybe through a function to ensure/prevent some behavior.
Activity
DzmitryShylovich commentedon Dec 12, 2016
Provide a small repro in plunkr
parliament718 commentedon Dec 12, 2016
https://plnkr.co/edit/mUXkCli6CUEyNlbn2PZV?p=preview
[-]shades[/-][+]ngOutletContext causes template to re-initialize on data changes[/+]DzmitryShylovich commentedon Mar 3, 2017
Still an issue in 4.x http://plnkr.co/edit/J3pPvM0Cstq2BtTaxY2h?p=preview
@parliament718 workaround https://plnkr.co/edit/kR2oTyTubaAS4UdFISM6?p=preview
pkozlowski-opensource commentedon Jul 19, 2017
The issue described here is a combination of 2 implementation decisions:
ngTemplateOutletwill re-create templates as soon as a bound context changes:angular/packages/common/src/directives/ng_template_outlet.ts
Lines 51 to 60 in 5344be5
We could change implementation of the
ngTemplateOutletalthough it would be a bit tricky. before doing so I will dig into part of the view / CD engine that re-creates object literals.ghetolay commentedon Jul 19, 2017
I think the root problem for
ngTemplateOutletisViewContainerRef.contextto be readonly so we can't change a context but just create it once and then mutate it.When @DzmitryShylovich tried to fix that issue this was his main issue, if user provides a new context we can't just replace it but we would have to run a differ and mutate the actual context to shape it exactly like the new context being passed.
I find it weird for Angular to enforce mutation of data here when it's more about immutable data everywhere else.
So I think there should be a way to change the context (the reference), maybe through a function to ensure/prevent some behavior.
fix(common): don't recreate view when context shape doesn't change
fix(common): don't recreate view when context shape doesn't change (#…
fix(common): don't recreate view when context shape doesn't change (a…
fix(common): don't recreate view when context shape doesn't change (a…
fix(common): don't recreate view when context shape doesn't change (a…
angular-automatic-lock-bot commentedon Sep 12, 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.