Angular的property binding一个例子

66 阅读1分钟

语法,在中括号里填上html标签的属性名称:

<h2>Products</h2>

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

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

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

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

最后渲染出来的html源代码:

要获取更多Jerry的原创文章,请关注公众号"汪子熙":