-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Isolated scope not isolated #7716
Comments
Where does it say that? What is happening is, So it's basically doing exactly what you'd expect it to --- the transcluded content is linked against a new child of the isolate scope directive's parent. You can get different behaviour if you call the transclude function manually, rather than relying on ng-transclude. Anyways, as for documentation regarding that change, the place you want to look is CHANGELOG.md --- In particular, this line from 1.2.0:
|
Hi Below is the extract from the documentation. What this tells me is that if the transclude option isn't set the {{name}} expression would be bound against the isolated scope, but (please see the fiddles from the original comment) that behaviour has changed in 1.2.0. It now seems that the isolated scope is not truly isolated. The behaviour is as expected when transclude is set to true, but when the transclude, and ng-transclude is removed it makes sense to bind to isolated scope, which happened in 1.0.8, but not in 1.2.0
|
You would "expect" that However, this is not the case since 909cabd (1.2.0) --- with the exception of when you explicitly link the transcluded content against the isolate scope (http://jsfiddle.net/ajwQR/) Basically, isolate scopes were broken pre-1.2.0, and have since become unbroken. At least as far as their "isolated" property is concerned. |
I think that excerpt is actually talking about the fact that if the Perhaps the bit about transclude is worded poorly as it seems to imply that the "original contents" of the element containing the directive will be bound differently based on whether we use transclude or not. But this is not the case.
|
If you have a template and do use transclusion, then you can inject this original content effectively bound to whichever scope you want it to be bound to, but if you do not give it a specific scope, or use the ng-transclude directive to handle this injection for you, then it will use a child of the original scope. |
Oh, and having a template is not actually necessary at all, it turns out. You can transclude content regardless -- although I couldn't explain why we let you do that without a template :> |
Sweet I understand the isolation now. I think the wording in the doc could Thanks. On Thu, Jun 5, 2014 at 9:16 PM, Caitlin Potter [email protected]
|
@TheManFran I seems like this issue is resolved, so I'm going to close it. Feel free to reopen it if there's more to it. |
Thanks
|
I was following the dev guide (https://docs.angularjs.org/guide/directive) on isolated scope and was not experiencing the described behaviour. The section that describes the behaviour of the transclude option mentioned that if the transclude wasn't included the expression would have resolved to the isolated scope value, in this case the name 'Jeff'. I didn't experience this behaviour, as the binding was made to the external scope.
I realized this has changed between version 1.0.8 (http://jsfiddle.net/TheManFran/wqSeJ/1/) and version 1.2.0 (http://jsfiddle.net/TheManFran/CbLcw/1/). I can't find any documentation that explains this change.
To me this feels like a bug as one expects the bindings with isolated scope not to bind to the external scope.
The text was updated successfully, but these errors were encountered: