Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

A more detailed documentation is needed for directive scopes #5761

Closed
behrangsa opened this issue Jan 13, 2014 · 1 comment
Closed

A more detailed documentation is needed for directive scopes #5761

behrangsa opened this issue Jan 13, 2014 · 1 comment

Comments

@behrangsa
Copy link

At the moment, in the ng.$compile docs, it is mentiond that:

scope
If set to true, then a new scope will be created for this directive. If multiple directives on the same element request a new scope, only one new scope is created. The new scope rule does not apply for the root of the template since the root of the template always gets a new scope.

If set to {} (object hash), then a new "isolate" scope is created. The 'isolate' scope differs from normal scope in that it does not prototypically inherit from the parent scope. This is useful when creating reusable components, which should not accidentally read or modify data in the parent scope.


While it is mentioned that:

If multiple directives on the same element request a new scope, only one new scope is created.

It is not mentioned what happens when there are multiple directives on an element and

a - all of them request an isolated scope
b - some request an isolated scope and some request a new scope


In particular, when a custom directive with an isolated scope and ng-model are on the same element (scenario b), its behavior could be confusing (see here, here, and here).

@behrangsa
Copy link
Author

Thanks! 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants