Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit cf0e742

Browse files
naomiblackchirayuk
authored andcommitted
docs(directives): Edit directive descriptions and add examples
1 parent 8573766 commit cf0e742

File tree

2 files changed

+31
-34
lines changed

2 files changed

+31
-34
lines changed

lib/directive/ng_model.dart

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,10 @@ class InputCheckbox {
332332

333333
/**
334334
* Creates a two-way databinding between the `ng-model` expression
335-
* and the `<input>` or `<textarea>` string-based input elements.
335+
* and the `<input>` or `<textarea>` string-based input elements. `Selector: textarea[ng-model]`
336+
* or `input[type=text|password|url|email|search|tel][ng-model]`
336337
*
337-
* **Usage**
338+
* **Usage**
338339
*
339340
* <input type="text|url|password|email|search|tel" ng-model="myModel">
340341
* <textarea ng-model="myModel"></textarea>
@@ -397,7 +398,7 @@ class InputTextLike {
397398

398399
/**
399400
* Creates a two-way databinding between the `ng-model` expression
400-
* and a numeric input element. `Selector:input[type=number|range][ng-model]
401+
* and a numeric input element. `Selector:input[type=number|range][ng-model]`
401402
*
402403
* **Usage**
403404
*
@@ -469,17 +470,17 @@ class InputNumberLike {
469470
}
470471

471472
/**
472-
* This directive affects which IDL attribute will be used to read the value of
473-
* date/time related input directives. Recognized values for this directive are:
473+
* Subordinate directive to [InputDateLike] that specifies the type for date/time related values.
474+
* `Selector: input[type=date|time|datetime|datetime-local|month|week][ng-model][ng-bind-type]`
475+
*
476+
* This directive controls which IDL attribute is read and thus sets the type. This allows an app
477+
* to support browsers that deviate from the HTML5 standard for date/time.
474478
*
475-
* - [DATE]: [dom.InputElement].valueAsDate will be read.
476-
* - [NUMBER]: [dom.InputElement].valueAsNumber will be read.
477-
* - [STRING]: [dom.InputElement].value will be read.
479+
* Recognized values for this directive are:
478480
*
479-
* The default is [DATE]. Use other settings, e.g., when an app needs to support
480-
* browsers that treat date-like inputs as text (in such a case the [STRING]
481-
* kind would be appropriate) or, for browsers that fail to conform to the
482-
* HTML5 standard in their processing of date-like inputs.
481+
* - [DATE]: `dom.InputElement.valueAsDate` is read. (This is the default.)
482+
* - [NUMBER]: `dom.InputElement.valueAsNumber` is read.
483+
* - [STRING]: `dom.InputElement.value` is read.
483484
*/
484485
@Decorator(selector: 'input[type=date][ng-model][ng-bind-type]', visibility: Visibility.LOCAL)
485486
@Decorator(selector: 'input[type=time][ng-model][ng-bind-type]', visibility: Visibility.LOCAL)

lib/directive/ng_src_boolean.dart

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
11
part of angular.directive;
22

33
/**
4-
* Allows adding and removing the boolean attributes from the element.
4+
* Sets boolean HTML attributes as true or false. `Selector:
5+
* [ng-checked]` or `[ng-disabled]` or `[ng-multiple]` or `[ng-open]` or `[ng-readonly]` or
6+
* `[ng-required]` or `[ng-selected]`
57
*
6-
* Using `<button disabled="{{false}}">` does not work since it would result
7-
* in `<button disabled="false">` rather than `<button>`.
8-
* Browsers change behavior based on presence/absence of the attribute rather
9-
* its value.
8+
* Since the presence of a boolean attribute on an element represents the true value,
9+
* and the absence of the attribute represents the false value, `<button disabled="{{false}}">`
10+
* would produce `<button disabled="false">` (which disables the button) rather than the desired
11+
* result: `<button>`.
1012
*
11-
* For this reason we provide alternate `ng-`attribute directives to
12-
* add/remove boolean attributes such as `<button ng-disabled="{{false}}">`
13-
* which will result in proper removal of the attribute.
13+
* Angular provides alternate `ng-`attribute directives that set elements to true or false
14+
* by adding or removing boolean attributes as needed.
1415
*
15-
* The full list of supported attributes are:
16+
* #Example
1617
*
17-
* - [ng-checked]
18-
* - [ng-disabled]
19-
* - [ng-multiple]
20-
* - [ng-open]
21-
* - [ng-readonly]
22-
* - [ng-required]
23-
* - [ng-selected]
18+
* <button ng-disabled="isDisabled">Button</button>
2419
*/
2520
@Decorator(selector: '[ng-checked]', map: const {'ng-checked': '=>checked'})
2621
@Decorator(selector: '[ng-disabled]', map: const {'ng-disabled': '=>disabled'})
@@ -82,14 +77,15 @@ class NgSource {
8277
}
8378

8479
/**
85-
* In SVG some attributes have a specific syntax. Placing `{{interpolation}}` in
86-
* those attributes will break the attribute syntax, and browser will clear the
87-
* attribute.
80+
* Provides a generic way to use `{{ }}` interpolation for attributes within validated SVG
81+
* elements. `Selector: [ng-attr-*]`
8882
*
89-
* The `ng-attr-*` is a generic way to use interpolation without breaking the
90-
* attribute syntax validator. The `ng-attr-` part get stripped.
83+
* Because the browser validates SVG syntax, using `{{interpolation}}` inside some validated
84+
* `<svg>` elements causes the browser to ignore the interpolated value. The `ng-attr-*` selector
85+
* inserts `{{ }}` into the element without breaking validation. (The `ng-attr-` part is stripped
86+
* out during rendering.)
9187
*
92-
* @example
88+
* #Example
9389
* <svg>
9490
* <circle ng-attr-cx="{{cx}}"></circle>
9591
* </svg>

0 commit comments

Comments
 (0)