2

I'm reading ng-book on angular2 and there is the following there:

Template elements are special elements used to create views that can be dynamically manipulated. In order to make working with templates simpler, Angular provides some syntatic sugar to create templates, so we often don’t create them by hand. For instance, when we write:

<do-check-item
        *ngFor="let comment of comments"
        [comment]="comment"
        (onRemove)="removeComment($event)">
</do-check-item>

This gets converted into:

<do-check-item
        template="ngFor let comment of comments; #i=index"
        [comment]="comment"
        (onRemove)="removeComment($event)">
</do-check-item>

Which then gets converted into:

<template
    ngFor
    [ngForOf]="comments"
    let-comment="$implicit"
    let-index="i">
    <do-check-item
            [comment]="comment"
            (onRemove)="removeComment($event)">
    </do-check-item>
</template>

But they don't define the rules the govern this transition. Can anyone explain or point to the relevant resource to read about the rules?

As I understand, all bindings are left on the component tag, while everything else is taken out and placed on the template element.

Max Koretskyi
  • 101,079
  • 60
  • 333
  • 488
  • please read this link https://angular.io/docs/ts/latest/guide/structural-directives.html#!#template might help you Angular inserts the template's content into the DOM when condition is true. – rashfmnb Jan 13 '17 at 16:54

0 Answers0