在 Angular2 表达式模板语法中使用两对括号
Use of two pairs of brackets in Angular2 expression template syntax
我在 John Papa 的 'Tour of Heroes' 示例应用程序的 app.component.ts 文件中看到以下内容:
<a [router-link]="[routes.dashboard]">Dashboard</a>
<a [router-link]="[routes.heroes]">Heroes</a>
我明白等号左边括号的用法(绑定),但是不明白右边括号的用法
有什么想法吗?谢谢!
那些用于定义数组。
摘自RouterLink documentation:
RouterLink expects the value to be an array of route names, followed by the params for that level of routing. For instance ['/Team', {teamId: 1}, 'User', {userId: 2}] means that we want to generate a link for the Team route with params {teamId: 1}, and with a child route User with params {userId: 2}.
我在 John Papa 的 'Tour of Heroes' 示例应用程序的 app.component.ts 文件中看到以下内容:
<a [router-link]="[routes.dashboard]">Dashboard</a>
<a [router-link]="[routes.heroes]">Heroes</a>
我明白等号左边括号的用法(绑定),但是不明白右边括号的用法
有什么想法吗?谢谢!
那些用于定义数组。 摘自RouterLink documentation:
RouterLink expects the value to be an array of route names, followed by the params for that level of routing. For instance ['/Team', {teamId: 1}, 'User', {userId: 2}] means that we want to generate a link for the Team route with params {teamId: 1}, and with a child route User with params {userId: 2}.