//.ts中
import { Component } from '@angular/core';
//装饰器语法
@Comonent({
selector:"app-main",//将来可在使用时<app-main/>
templateUrl:"./app-main.html",//html模板
styleUrls:["./app-style.css"]//css可引入多个
})
class AppMain{
list:[{name:'tom',age:19},{name:"jarray",age:20},{name:"lishao",age:18}]
}
//app-main.html
<div *ngFor="let item of list">
...//内部内容
</div>
<div *ngIf="flag"></div>
<div *ngFor="let item of list">
<div>{{item.name}}</div>
</div>
<div *ngFor="let item of list">
<a [title]="item.name+'detail'">
<div>{{item.name}}</div>
</a>
</div>
<div *ngFor="let item of list">
<a [title]="item.name+'detail'">
<div>{{item.name}}</div>
</a>
<button (click)="share()">share</button>
</div>