|
159 | 159 | *
|
160 | 160 | * @description
|
161 | 161 | *
|
162 |
| - * We shouldn't do this, because it will make the button enabled on Chrome/Firefox but not on IE8 and older IEs: |
| 162 | + * This directive sets the `disabled` attribute on the element if the |
| 163 | + * {@link guide/expression expression} inside `ngDisabled` evaluates to truthy. |
| 164 | + * |
| 165 | + * A special directive is necessary because we cannot use interpolation inside the `disabled` |
| 166 | + * attribute. The following example would make the button enabled on Chrome/Firefox |
| 167 | + * but not on older IEs: |
| 168 | + * |
163 | 169 | * ```html
|
164 |
| - * <div ng-init="scope = { isDisabled: false }"> |
165 |
| - * <button disabled="{{scope.isDisabled}}">Disabled</button> |
| 170 | + * <div ng-init="isDisabled = false"> |
| 171 | + * <button disabled="{{isDisabled}}">Disabled</button> |
166 | 172 | * </div>
|
167 | 173 | * ```
|
168 | 174 | *
|
169 |
| - * The HTML specification does not require browsers to preserve the values of boolean attributes |
170 |
| - * such as disabled. (Their presence means true and their absence means false.) |
| 175 | + * This is because the HTML specification does not require browsers to preserve the values of |
| 176 | + * boolean attributes such as `disabled` (Their presence means true and their absence means false.) |
171 | 177 | * If we put an Angular interpolation expression into such an attribute then the
|
172 | 178 | * binding information would be lost when the browser removes the attribute.
|
173 |
| - * The `ngDisabled` directive solves this problem for the `disabled` attribute. |
174 |
| - * This complementary directive is not removed by the browser and so provides |
175 |
| - * a permanent reliable place to store the binding information. |
176 | 179 | *
|
177 | 180 | * @example
|
178 | 181 | <example>
|
|
191 | 194 | *
|
192 | 195 | * @element INPUT
|
193 | 196 | * @param {expression} ngDisabled If the {@link guide/expression expression} is truthy,
|
194 |
| - * then special attribute "disabled" will be set on the element |
| 197 | + * then the `disabled` attribute will be set on the element |
195 | 198 | */
|
196 | 199 |
|
197 | 200 |
|
|
0 commit comments