docs(API): 翻译 ng-for-of

This commit is contained in:
Zhicheng Wang 2018-08-30 12:56:38 +08:00
parent c3039b42a5
commit 9f34b155c4
2 changed files with 62 additions and 0 deletions

View File

@ -1,5 +1,7 @@
## 优先级
按照下列优先级进行翻译:
URL|浏览量|占比
---|---|----
common/http/HttpClient | 7,263 | 2.26

View File

@ -26,21 +26,47 @@ export class NgForOfContext<T> {
* The `NgForOf` 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.
* <p>`NgForOf` </p>
*
* ### Local Variables
*
* ###
*
* `NgForOf` provides several exported values that can be aliased to local variables:
*
* `NgForOf` 使
*
* - `$implicit: T`: The value of the individual items in the iterable (`ngForOf`).
*
* `$implicit: T``ngForOf`
*
* - `ngForOf: NgIterable<T>`: The value of the iterable expression. Useful when the expression is
* more complex then a property access, for example when using the async pipe (`userStreams |
* async`).
*
* `ngForOf: NgIterable<T>`访使 `async` `userStreams |
* async`)。
*
* - `index: number`: The index of the current item in the iterable.
*
* `index: number`
*
* - `first: boolean`: True when the item is the first item in the iterable.
*
* `first: boolean` `true`
*
* - `last: boolean`: True when the item is the last item in the iterable.
*
* `last: boolean` `true`
*
* - `even: boolean`: True when the item has an even index in the iterable.
*
* `even: boolean` `true`
*
* - `odd: boolean`: True when the item has an odd index in the iterable.
*
* `odd: boolean` `true`
*
* ```
* <li *ngFor="let user of userObservable | async as users; index as i; first as isFirst">
* {{i}}/{{users.length}}. {{user}} <span *ngIf="isFirst">default</span>
@ -49,19 +75,38 @@ export class NgForOfContext<T> {
*
* ### Change Propagation
*
* ###
*
* When the contents of the iterator changes, `NgForOf` makes the corresponding changes to the DOM:
*
* `NgForOf` DOM
*
* * When an item is added, a new instance of the template is added to the DOM.
*
* DOM
*
* * When an item is removed, its template instance is removed from the DOM.
*
* DOM
*
* * When items are reordered, their respective templates are reordered in the DOM.
*
* DOM
*
* * Otherwise, the DOM element for that item will remain the same.
*
* DOM
*
* Angular uses object identity to track insertions and deletions within the iterator and reproduce
* those changes in the DOM. This has important implications for animations and any stateful
* controls (such as `<input>` elements which accept user input) that are present. Inserted rows can
* be animated in, deleted rows can be animated out, and unchanged rows retain any unsaved state
* such as user input.
*
* Angular 使 DOM
* `<input>`
*
*
* It is possible for the identities of elements in the iterator to change while the data does not.
* This can happen, for example, if the iterator produced from an RPC to the server, and that
* RPC is re-run. Even if the data hasn't changed, the second response will produce objects with
@ -69,16 +114,28 @@ export class NgForOfContext<T> {
* elements were deleted and all new elements inserted). This is an expensive operation and should
* be avoided if possible.
*
* 使 RPC
* RPC 使Angular DOM
* 仿
*
* To customize the default tracking algorithm, `NgForOf` supports `trackBy` option.
* `trackBy` takes a function which has two arguments: `index` and `item`.
* If `trackBy` is given, Angular tracks changes by the return value of the function.
*
* `NgForOf` `trackBy`
* `trackBy` `index` `item`
* `trackBy`Angular 使
*
* ### Syntax
*
* ###
*
* - `<li *ngFor="let item of items; index as i; trackBy: trackByFn">...</li>`
*
* With `<ng-template>` element:
*
* `<ng-template>`
*
* ```
* <ng-template ngFor let-item [ngForOf]="items" let-i="index" [ngForTrackBy]="trackByFn">
* <li>...</li>
@ -87,9 +144,12 @@ export class NgForOfContext<T> {
*
* ### Example
*
* ###
*
* See a [live demo](http://plnkr.co/edit/KVuXxDp0qinGDyo307QW?p=preview) for a more detailed
* example.
*
* [线](http://plnkr.co/edit/KVuXxDp0qinGDyo307QW?p=preview)了解详情。
*
*/
@Directive({selector: '[ngFor][ngForOf]'})