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

Commit 65df5da

Browse files
committed
docs(ngDisabled): clarify the explanation of attributes & interpolation
Closes #11032 Closes #11133
1 parent 0689c36 commit 65df5da

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/ng/directive/attrs.js

+12-9
Original file line numberDiff line numberDiff line change
@@ -159,20 +159,23 @@
159159
*
160160
* @description
161161
*
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+
*
163169
* ```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>
166172
* </div>
167173
* ```
168174
*
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.)
171177
* If we put an Angular interpolation expression into such an attribute then the
172178
* 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.
176179
*
177180
* @example
178181
<example>
@@ -191,7 +194,7 @@
191194
*
192195
* @element INPUT
193196
* @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
195198
*/
196199

197200

0 commit comments

Comments
 (0)