-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Scope() on template of isolated directive is wrong #5704
Comments
Ah... not really. But seriously... from the perspective of the template the scope IS the isolated scope. It's linked with it. So it just makes sense scope() would return that isolated scope. It's isolated from the point of view of the element on which the directive sits, but on the template of that directive it effectively becomes THE scope. |
Well, that's not the way things work anymore, the isolate scopes are isolated similar to the way the shadow DOM is isolated from the light DOM (that might be a bit of a stretch, but the reasoning is similar) |
So basically the template is linked against a scope no one can ever see??? That sounds kind of strange. The template is an integral part of the directive. And for debugging purposes, how can I tell which scope an element was linked against? At the least, I'd expect the data() of the template elements to contain that scope. Though, as mentioned before, I see the template as an integral part of the directive. If the directive has an isolated scope then so does the template (it is linked with it). |
You can see it with the |
Yeah... true. I totally understand the separation of isolated scope people are aiming for, I feel that in this specific case this has gone a bit too far to the point where it interferes and makes life harder instead of easier. |
Sorry, but this works as intended. Closing this. |
Assuming this does work as intended, is there any way to know given an element of a template that it is indeed part of a template? |
You can check the properties |
You mean traverse the tree up until isolatedScope() returns something? I have to admit that to me it seems really strange. |
@caitp @tbosch I think I disagree that this is the intended behavior. My interpretation of 27e9340, which I read 3 times before saying that I think you are wrong :) - Invoking The The only edge case is when you are querying an element which is the root of an isolated scope, where one directive uses the isolated scope but all other directives use the parent scope (or a new scope created by This works just as I described for directives that have a |
My input is that we probably should fix jqLite#scope to not also search for $isolateScope. No part of angular core depends on this, and it kind of breaks the whole "isolation" thing. |
If this is what should be done or what was intended in this commit, then what is the point of separating |
it may have been necessary to separate them, because of the difference between sync and async compilation. But I'm not positive. I can't really think of a good higher-level reason for the separation |
Maybe we should ask @IgorMinar for his opinion on this and his actual intentions in his commit (27e9340) |
I have a directive which has an isolated scope and a template.
Although the bindings in the template refer to the isolated scope as they should, scope() and data() do not show this scope.
For all purposes the scope of the template is indeed the isolated scope, so I'd expect scope() to return it (or at least to see it in data()).
This makes debugging a bit difficult.
See
http://jsfiddle.net/yarontt/S5bnE/
The text was updated successfully, but these errors were encountered: