1. *ngFor="let item of items; index as productId"
//相当于 v-for="(item,index) in items"
<div *ngFor="let item of items; let i = index">{{i + 1}} - {{item.name}}</div>
//另外一种获取index的方法
2. *ngIf。判断。<p *ngIf="product.description">
//相当于 <p v-if="product.description">
3. [] 属性绑定语法。<img [src]="pic" />
//相当于 <img :src="pic" />
4. () 事件绑定。 <button (click)="share()">
//相当于<button @click="share()">
5. [hidden]="true/false" 。相当于v-show。
Angular模板语法总结
最新推荐文章于 2024-01-16 17:06:54 发布