Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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

@behrangsa

Description

@behrangsa

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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions