angular学习之通俗易懂篇-----[routerLink]绑定数据

html文件:

<a *ngFor="let item of title_arr" [routerLink]="item.path" routerLinkActive="active">{{item.name}}</a>

ts文件:

 title_arr=[{
    name:'京东超市',
    path:'/componentA/supermarket'
  },{
    name:'京东到家',
    path:'/componentA/tohome'
  },{
    name:'免费水果',
    path:'/componentA/freefruit'
  }]
原文地址:https://www.cnblogs.com/zhaoyingzhen/p/14234154.html