diff --git a/src/ng/compile.js b/src/ng/compile.js index b4d573e1230a..d4e1971041b0 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -134,11 +134,15 @@ * and other directives used in the directive's template will also be excluded from execution. * * #### `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. + * Scope property can have one of the following values: * - * **If set to `{}` (object hash),** then a new "isolate" scope is created. The 'isolate' scope differs from + * * **`false`:** No scope will be created for the directive. The directive will use its parent's scope. + * + * * **`true`:** 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. + * + * * **`{}`(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. @@ -178,6 +182,20 @@ * For example, if the expression is `increment(amount)` then we can specify the amount value * by calling the `localFn` as `localFn({amount: 22})`. * + * In general it's possible to apply more than one directive to one element, but there might be limitations depending on the type of scope required + * by the directives. Following points will help to understand these limitations. For a better understanding only two directives are taken into + * account, but it is also applicable for several directives. + * + * * **no scope** + **no scope** => Two directives which don't require their own scope will use their parent's scope + * * **child scope** + **no scope** => Both directives will share one single child scope + * * **child scope** + **no scope** => Both directives will share one single child scope + * * **isolated scope** + **no scope** => The isolated directive will use it's own created isolated scope. The other directive will use + * its parent's scope + * * **isolated scope** + **child scope** => **Won't work!** Only one scope can be related to one element. Therefore these directives cannot + * be applied to the same element. + * * **isolated scope** + **isolated scope** => **Won't work!** Only one scope can be related to one element. Therefore these directives + * cannot be applied to the same element. + * * * #### `bindToController` * When an isolate scope is used for a component (see above), and `controllerAs` is used, `bindToController: true` will