From 86211eb5f047824a95286991748a7dea2f7aa729 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Mon, 6 Apr 2015 11:47:38 +0200 Subject: [PATCH] doc(directives): add inline documentation Closes #1240 --- modules/angular2/src/directives/for.js | 29 +++++++++++++++++++ modules/angular2/src/directives/if.js | 19 ++++++++++++ .../angular2/src/directives/non_bindable.js | 12 ++++++++ modules/angular2/src/directives/switch.js | 5 +++- 4 files changed, 64 insertions(+), 1 deletion(-) diff --git a/modules/angular2/src/directives/for.js b/modules/angular2/src/directives/for.js index 1b74fe8392..31bb73f22f 100644 --- a/modules/angular2/src/directives/for.js +++ b/modules/angular2/src/directives/for.js @@ -5,6 +5,35 @@ import {isPresent, isBlank} from 'angular2/src/facade/lang'; import {ListWrapper} from 'angular2/src/facade/collection'; /** + * The `For` directive instantiates a template once per item from an iterable. The context for each + * instantiated template inherits from the outer context with the given loop variable set to the + * current item from the iterable. + * + * It is possible to alias the `index` to a local variable that will be set to the current loop + * iteration in the template context. + * + * When the contents of the iterator changes, `For` makes the corresponding changes to the DOM: + * + * * When an item is added, a new instance of the template is added to the DOM. + * * When an item is removed, its template instance is removed from the DOM. + * * When items are reordered, their respective templates are reordered in the DOM. + * + * # Example + * + * ``` + * + * ``` + * + * # Syntax + * + * - `
  • ...
  • ` + * - `
  • ...
  • ` + * - `` + * * @publicModule angular2/directives */ @Viewport({ diff --git a/modules/angular2/src/directives/if.js b/modules/angular2/src/directives/if.js index 90c0adb433..e1af844739 100644 --- a/modules/angular2/src/directives/if.js +++ b/modules/angular2/src/directives/if.js @@ -3,6 +3,25 @@ import {ViewContainer} from 'angular2/src/core/compiler/view_container'; import {isBlank} from 'angular2/src/facade/lang'; /** + * The `If` directive removes or recreates a portion of the DOM tree based on an {expression}. If + * the expression assigned to `if` evaluates to a false value then the element is removed from the + * DOM, otherwise a clone of the element is reinserted into the DOM. + * + * # Example: + * + * ``` + *
    + * + * {{errorCount}} errors detected + *
    + * ``` + * + * # Syntax + * + * - `
    ...
    ` + * - `
    ...
    ` + * - `` + * * @publicModule angular2/directives */ @Viewport({ diff --git a/modules/angular2/src/directives/non_bindable.js b/modules/angular2/src/directives/non_bindable.js index b1e300b769..b4858b31eb 100644 --- a/modules/angular2/src/directives/non_bindable.js +++ b/modules/angular2/src/directives/non_bindable.js @@ -1,6 +1,18 @@ import {Decorator} from 'angular2/src/core/annotations/annotations'; /** + * The `NonBindable` directive tells Angular not to compile or bind the contents of the current + * DOM element. This is useful if the element contains what appears to be Angular directives and + * bindings but which should be ignored by Angular. This could be the case if you have a site that + * displays snippets of code, for instance. + * + * Example: + * + * ``` + *
    Normal: {{1 + 2}}
    // output "Normal: 3" + *
    Ignored: {{1 + 2}}
    // output "Ignored: {{1 + 2}}" + * ``` + * * @publicModule angular2/directives */ @Decorator({ diff --git a/modules/angular2/src/directives/switch.js b/modules/angular2/src/directives/switch.js index 1756ca6189..b71d163c1e 100644 --- a/modules/angular2/src/directives/switch.js +++ b/modules/angular2/src/directives/switch.js @@ -20,7 +20,7 @@ import {Parent} from 'angular2/src/core/annotations/visibility'; * evaluated. If a matching expression is not found via a when attribute then an element with the * default attribute is displayed. * - * Example: + * # Example: * * ``` * @@ -29,6 +29,7 @@ import {Parent} from 'angular2/src/core/annotations/visibility'; * * * ``` + * * @publicModule angular2/directives */ @Decorator({ @@ -181,6 +182,8 @@ export class SwitchWhen { * * @publicModule angular2/directives * ``` + * + * @publicModule angular2/directives */ @Viewport({ selector: '[switch-default]'