Skip to content

Commit a6a2ac4

Browse files
naomiblackjbdeboer
authored andcommitted
docs(directives): edits to directive docs
1 parent d068242 commit a6a2ac4

File tree

8 files changed

+48
-37
lines changed

8 files changed

+48
-37
lines changed

lib/core/annotation_src.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ bool _applyAuthorStylesDeprecationWarningPrinted = false;
236236
bool _resetStyleInheritanceDeprecationWarningPrinted = false;
237237

238238
/**
239-
* Meta-data marker placed on a class which should act as a controller for the
239+
* Annotation placed on a class which should act as a controller for the
240240
* component. Angular components are a light-weight version of web-components.
241241
* Angular components use shadow-DOM for rendering their templates.
242242
*
@@ -249,7 +249,8 @@ bool _resetStyleInheritanceDeprecationWarningPrinted = false;
249249
*
250250
* * `attach()` - Called on first [Scope.apply()].
251251
* * `detach()` - Called on when owning scope is destroyed.
252-
* * `onShadowRoot(ShadowRoot shadowRoot)` - Called when [ShadowRoot] is loaded.
252+
* * `onShadowRoot(ShadowRoot shadowRoot)` - Called when
253+
* [ShadowRoot](https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart-dom-html.ShadowRoot) is loaded.
253254
*/
254255
class Component extends Directive {
255256
/**
@@ -362,7 +363,7 @@ class Component extends Directive {
362363
}
363364

364365
/**
365-
* Meta-data marker placed on a class which should act as a directive.
366+
* Annotation placed on a class which should act as a directive.
366367
*
367368
* Angular directives are instantiated using dependency injection, and can
368369
* ask for any injectable object in their constructor. Directives
@@ -402,7 +403,7 @@ class Decorator extends Directive {
402403
}
403404

404405
/**
405-
* Meta-data marker placed on a class which should act as a controller for your
406+
* Annotation placed on a class which should act as a controller for your
406407
* application.
407408
*
408409
* Controllers are essentially [Decorator]s with few key differences:

lib/directive/a_href.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
part of angular.directive;
22

33
/**
4-
* Modifies the default behavior of the HTML `<a>` element to allow for data binding.
4+
* Modifies the default behavior of the HTML `<a>` element to prevent navigation from the current page when the `href`
5+
* attribute is empty. `Selector: a[href]`
56
*
6-
* When an `href` tag is empty, or when used with `ng-click`, this directive intercepts and
7-
* modifies the default behavior of the `<a>` element. This change permits the easy
8-
* creation of action links with the [OnClick] directive, without changing the location or causing
9-
* a page reload.
7+
* This change permits the easy creation of action links with the [OnClick] directive, without changing the location
8+
* or causing a page reload.
109
*
11-
* Example:
10+
* # Example
1211
*
1312
* <a href="" ng-click="model.save()">Save</a>
1413
*/

lib/directive/module.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
* and providing them as part of a custom library.
88
*
99
* Directives consist of a class specifying the behavior, and a directive annotation (such as a
10-
* [Decorator] or a [Component]) that describes when the behavior should be applied.
10+
* [Decorator](#angular-core-annotation.Decorator) or a [Component](#angular-core-annotation.Component)) that
11+
* describes when the behavior should be applied.
1112
*
1213
* For example:
1314
*

lib/directive/ng_base_css.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
part of angular.directive;
2-
2+
/**
3+
* Specifies a base CSS to use for components defined under the directive. `Selector:[ng-base-css]`
4+
*
5+
* The NgBaseCss directive is typically used at the top of an Angular application, so that everything in the
6+
* application inherits the specified stylesheet.
7+
*
8+
* # Example
9+
* <div ng-base-css="my_application.css">
10+
*/
311
@Decorator(selector: '[ng-base-css]')
412
class NgBaseCss {
513
List<String> _urls = const [];

lib/directive/ng_bind.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ part of angular.directive;
22

33
/**
44
* Replaces the text content of the specified HTML element with the value of a given expression,
5-
* and updates the text content when the value of that expression changes.
5+
* and updates the text content when the value of that expression changes. `Selector:[ng-bind]`
66
*
77
* Typically, you don't use ngBind directly, but instead you use the double
8-
* curly markup like `{{ expression }}` which is similar but less verbose.
8+
* curly markup `{{ expression }}` which is similar but less verbose.
99
*
10-
* It is preferrable to use `ng-bind` instead of `{{ expression }}` when a template
11-
* is momentarily displayed by the browser in its raw state before Angular
12-
* compiles it. Since `ng-bind` is an element attribute, it makes the bindings
13-
* invisible to the user while the page is loading.
10+
* When a page loads in the browser, the template is briefly displayed in its raw state before Angular compiles it.
11+
* For a large single-page app, this can result in `{{ }}` appearing while the page loads. You can prevent the template
12+
* bindings from showing by using `ng-bind` instead of `{{ }}`. Since `ng-bind` is an element attribute, nothing is
13+
* shown to the user.
1414
*
1515
* An alternative solution to this problem would be using the [ngCloak] directive.
1616
*/

lib/directive/ng_bind_html.dart

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

33
/**
4-
* Creates a binding that will innerHTML the result of evaluating the
5-
* `expression` bound to `ng-bind-html` into the current element in a secure
6-
* way. This expression must evaluate to a string. The innerHTML-ed content
7-
* will be sanitized using a default [NodeValidator] constructed as `new
8-
* dom.NodeValidatorBuilder.common()`. In a future version, when Strict
9-
* Contextual Escaping support has been added to Angular.dart, this directive
10-
* will allow one to bypass the sanitization and innerHTML arbitrary trusted
11-
* HTML.
4+
* Sanitizes an HTML string and invokes the browser's parser to insert the string into
5+
* the containing element in the DOM. `Selector:[ng-bind-html]`
126
*
13-
* Example:
7+
* # Example
148
*
15-
* <div ng-bind-html="htmlVar"></div>
9+
* <div ng-bind-html="expression"></div>
10+
*
11+
* The expression must evaluate to a string. Content is sanitized using a default [NodeValidator].
1612
*/
1713
@Decorator(
1814
selector: '[ng-bind-html]',
@@ -24,9 +20,10 @@ class NgBindHtml {
2420
NgBindHtml(this.element, dom.NodeValidator this.validator);
2521

2622
/**
27-
* Parsed expression from the `ng-bind-html` attribute.  The result of this
28-
* expression is innerHTML'd according to the rules specified in this class'
29-
* documentation.
23+
* Parsed expression from the `ng-bind-html` attribute. 
24+
*
25+
* The result of this expression is inserted into the containing element in the DOM according to the
26+
* rules specified in the documentation for the class.
3027
*/
3128
void set value(value) => element.setInnerHtml(
3229
value == null ? '' : value.toString(), validator: validator);

lib/directive/ng_bind_template.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
part of angular.directive;
22

33
/**
4-
* The [NgBindTemplate] specifies that the element text content should
5-
* be replaced with the interpolation of the template in the ngBindTemplate
6-
* attribute. Unlike ngBind, the ngBindTemplate can contain multiple {{ }}
7-
* expressions.
4+
* Replaces the text content of an element with an interpolated template. `Selector:[ng-bind-template]`
5+
*
6+
* # Example
7+
*
8+
* <div ng-bind-template="{{salutation}} {{name}}!">
9+
*
10+
* Unlike [ngBind], the `ng-bind-template` attribute can contain multiple `{{ }}` expressions.
811
*/
912
@Decorator(
1013
selector: '[ng-bind-template]',

lib/directive/ng_class.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ part of angular.directive;
1111
* * Array syntax: If the expression is an array, CSS classes are additively applied to the
1212
* element.
1313
* * Map syntax: If the expression is a map of 'key':value pairs, then the truthiness of the
14-
* value is used to determine which CSS classes are applied. (Here,
15-
* the keys correspond to the CSS classes to be applied.)
14+
* value is used to determine which CSS classes are applied. (Here, the keys correspond to the
15+
* CSS classes to be applied.)
1616
*
1717
* The directive won't add duplicate classes if a particular class was already set. When the
1818
* expression changes, CSS classes are updated to reflect the change.
@@ -82,6 +82,8 @@ class NgClass extends _NgClassBase {
8282
}
8383

8484
/**
85+
* Dynamically style only odd rows in a list via data.
86+
*
8587
* The `ngClassOdd` and `ngClassEven` directives work exactly as
8688
* {@link ng.directive:ngClass ngClass}, except it works in
8789
* conjunction with `ngRepeat` and takes affect only on odd (even) rows.

0 commit comments

Comments
 (0)