|
146 | 146 | * and other directives used in the directive's template will also be excluded from execution.
|
147 | 147 | *
|
148 | 148 | * #### `scope`
|
149 |
| - * **If set to `true`,** then a new scope will be created for this directive. If multiple directives on the |
150 |
| - * same element request a new scope, only one new scope is created. The new scope rule does not |
151 |
| - * apply for the root of the template since the root of the template always gets a new scope. |
| 149 | + * The scope property can be `true`, an object or a falsy value: |
152 | 150 | *
|
153 |
| - * **If set to `{}` (object hash),** then a new "isolate" scope is created. The 'isolate' scope differs from |
154 |
| - * normal scope in that it does not prototypically inherit from the parent scope. This is useful |
155 |
| - * when creating reusable components, which should not accidentally read or modify data in the |
156 |
| - * parent scope. |
| 151 | + * * **falsy:** No scope will be created for the directive. The directive will use its parent's scope. |
157 | 152 | *
|
158 |
| - * The 'isolate' scope takes an object hash which defines a set of local scope properties |
159 |
| - * derived from the parent scope. These local properties are useful for aliasing values for |
160 |
| - * templates. Locals definition is a hash of local scope property to its source: |
| 153 | + * * **`true`:** A new scope will be created for the directive's element. If multiple directives on the |
| 154 | + * same element request a new scope, only one new scope is created. The new scope rule does not apply |
| 155 | + * for the root of the template since the root of the template always gets a new scope. |
| 156 | + * |
| 157 | + * * **`{...}` (an object hash):** A new "isolate" scope is created for the directive's element. The |
| 158 | + * 'isolate' scope differs from normal scope in that it does not prototypically inherit from its parent |
| 159 | + * scope. This is useful when creating reusable components, which should not accidentally read or modify |
| 160 | + * data in the parent scope. |
| 161 | + * |
| 162 | + * The 'isolate' scope object hash defines a set of local scope properties derived from attributes on the |
| 163 | + * directive's element. These local properties are useful for aliasing values for templates. The keys in |
| 164 | + * the object hash map to the name of the property on the isolate scope; the values define how the property |
| 165 | + * is bound to the parent scope, via matching attributes on the directive's element: |
161 | 166 | *
|
162 | 167 | * * `@` or `@attr` - bind a local scope property to the value of DOM attribute. The result is
|
163 | 168 | * always a string since DOM attributes are strings. If no `attr` name is specified then the
|
|
190 | 195 | * For example, if the expression is `increment(amount)` then we can specify the amount value
|
191 | 196 | * by calling the `localFn` as `localFn({amount: 22})`.
|
192 | 197 | *
|
| 198 | + * In general it's possible to apply more than one directive to one element, but there might be limitations |
| 199 | + * depending on the type of scope required by the directives. The following points will help explain these limitations. |
| 200 | + * For simplicity only two directives are taken into account, but it is also applicable for several directives: |
| 201 | + * |
| 202 | + * * **no scope** + **no scope** => Two directives which don't require their own scope will use their parent's scope |
| 203 | + * * **child scope** + **no scope** => Both directives will share one single child scope |
| 204 | + * * **child scope** + **child scope** => Both directives will share one single child scope |
| 205 | + * * **isolated scope** + **no scope** => The isolated directive will use it's own created isolated scope. The other directive will use |
| 206 | + * its parent's scope |
| 207 | + * * **isolated scope** + **child scope** => **Won't work!** Only one scope can be related to one element. Therefore these directives cannot |
| 208 | + * be applied to the same element. |
| 209 | + * * **isolated scope** + **isolated scope** => **Won't work!** Only one scope can be related to one element. Therefore these directives |
| 210 | + * cannot be applied to the same element. |
| 211 | + * |
193 | 212 | *
|
194 | 213 | * #### `bindToController`
|
195 | 214 | * When an isolate scope is used for a component (see above), and `controllerAs` is used, `bindToController: true` will
|
|
0 commit comments