From b6819fe9bb1b43e8bbbc4265bb25b4a689596091 Mon Sep 17 00:00:00 2001 From: Judy Bogart Date: Wed, 16 Jan 2019 14:25:28 -0800 Subject: [PATCH] docs: add inpur vars doc (#27377) PR Close #27377 --- packages/common/src/directives/ng_for_of.ts | 15 ++++++++++++++- .../change_detection/differs/iterable_differs.ts | 8 ++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/common/src/directives/ng_for_of.ts b/packages/common/src/directives/ng_for_of.ts index 6fffe6e357..df197fb722 100644 --- a/packages/common/src/directives/ng_for_of.ts +++ b/packages/common/src/directives/ng_for_of.ts @@ -31,7 +31,7 @@ export class NgForOfContext { * The directive is placed on an element, which becomes the parent * of the cloned templates. * - * The `ngForOf` is generally used in the + * The `ngForOf` directive is generally used in the * [shorthand form](guide/structural-directives#the-asterisk--prefix) `*ngFor`. * In this form, the template to be rendered for each iteration is the content * of an anchor element containing the directive. @@ -124,11 +124,19 @@ export class NgForOfContext { */ @Directive({selector: '[ngFor][ngForOf]'}) export class NgForOf implements DoCheck { + /** + * The value of the iterable expression, which can be used as a + * [template input variable](guide/structural-directives#template-input-variable). + */ @Input() set ngForOf(ngForOf: NgIterable) { this._ngForOf = ngForOf; this._ngForOfDirty = true; } + /** + * A function that customizes the default tracking algorithm. + * When supplied, Angular tracks changes by the return value of the function. + */ @Input() set ngForTrackBy(fn: TrackByFunction) { if (isDevMode() && fn != null && typeof fn !== 'function') { @@ -155,6 +163,11 @@ export class NgForOf implements DoCheck { private _viewContainer: ViewContainerRef, private _template: TemplateRef>, private _differs: IterableDiffers) {} + /** + * The [template reference variable](guide/template-syntax#template-reference-variables--var-) + * for the expanded directive. + * Compare [template input variable](guide/structural-directives#template-input-variable) + */ @Input() set ngForTemplate(value: TemplateRef>) { // TODO(TS2.1): make TemplateRef>> once we move to TS v2.1 diff --git a/packages/core/src/change_detection/differs/iterable_differs.ts b/packages/core/src/change_detection/differs/iterable_differs.ts index 4fae01f8d9..8166bc4746 100644 --- a/packages/core/src/change_detection/differs/iterable_differs.ts +++ b/packages/core/src/change_detection/differs/iterable_differs.ts @@ -117,8 +117,12 @@ export interface IterableChangeRecord { export interface CollectionChangeRecord extends IterableChangeRecord {} /** - * An optional function passed into {@link NgForOf} that defines how to track - * items in an iterable (e.g. fby index or id) + * An optional function passed into the `NgForOf` directive that defines how to track + * changes for items in an iterable. + * When supplied, Angular tracks changes by the return value of the function. + * @param index The iteration index. + * @param item The item ID. + * @return The value to use for tracking changes. * * @publicApi */