Angular

Angular

五个常用特性:

  • *ngFor
<h2>Products</h2>

<div *ngFor="let product of products">
</div>
  • *ngIf
<h2>Products</h2>

<div *ngFor="let product of products">

  <h3>
    <a [title]="product.name + ' details'">
      {{ product.name }}
    </a>
  </h3>

  <p *ngIf="product.description">
    Description: {{ product.description }}
  </p>

</div>
  • 插值{{ }}
<div *ngFor="let product of products">

  <h3>
      {{ product.name }}
  </h3>

</div>
  • 属性绑定[ ]
<h2>Products</h2>

<div *ngFor="let product of products">

  <h3>
    <a [title]="product.name + ' details'">
      {{ product.name }}
    </a>
  </h3>

</div>
<h2>Products</h2>
  • 事件绑定
<h2>Products</h2>

<div *ngFor="let product of products">

  <h3>
    <a [title]="product.name + ' details'">
      {{ product.name }}
    </a>
  </h3>

  <p *ngIf="product.description">
    Description: {{ product.description }}
  </p>

  <button (click)="share()">
    Share
  </button>

</div>
原文地址:https://www.cnblogs.com/ed1s0n/p/14071273.html