1 新建一个data.ts引入本地的数据,导出数据
2 ts引入数据
import cartList from './data';
export class HeaderComponent implements OnInit {
public cartList:any=cartList
constructor() {
console.log(cartList)
}
3 组件渲染
<div *ngFor="let item of cartList">{{item.productName}}</div>