This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
SCOPE DESTRUCTION: Directive scope is never destroyed if immediately switched out and it has templateUrl. #9197
Comments
The issue is that the scope that the directive gets is already destroyed, in fact, it is already removed from the hierarchy |
Let me take a deeper look into this issue |
it looks like this is a bigger issue than expected |
@petebacondarwin assigning this to you since it's basically the same as lucas' dupe (lets just close it when we land the fix) |
petebacondarwin
added a commit
to petebacondarwin/angular.js
that referenced
this issue
Sep 29, 2014
Stop an asynchronous compilation when this is performed on an already destroyed scope Closes angular#9199 Closes angular#9079 Closes angular#8504 Closes angular#9197
petebacondarwin
added a commit
that referenced
this issue
Sep 29, 2014
The Changelog says that this also made it into v1.2.26. I just downloaded it from angularjs.org and didn't find this change in it... Edit: Probably because of this commit |
+1 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
We have a directive which uses
templateUrl
that is rendered within angSwitch
. There is a scenario where on page load the directive is rendered, but then immediately some conditions change causingngSwitch
to remove the directive from page. I found that in that case the directive's scope never gets destroyed.A Plunker demo is available here - http://plnkr.co/edit/QYnUKQrHA4uivJifsYne?p=preview
In the demo open browser's JS console. Notice that you will only see '>>>Created' message, but no '>>>Destroyed'. This bug happens only when the directive uses
templateUrl
. If you change the above demo code to usetemplate
instead then notice the bug is gone.The html snippet is:-
The controller code is:-
So as soon as the controller loads,
$scope.code
is set to 'blue' in next digest cycle, causing the directivered
to appear momentarily.The directive code is:-
If I use
template
instead oftemplateUrl
, then$destroy
is called. Thereplace: true
or isolated scope are not necessary to replicate this bug.The text was updated successfully, but these errors were encountered: