【发布时间】:2016-12-22 00:34:46
【问题描述】:
我正在尝试在表达式绑定中使用值。我知道这是无效的,但想知道是否有类似的可能。如果没有,有没有其他方法可以解决。
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'Home',
templateUrl: './views/home/home.html'
})
export class HomeComponent implements OnInit{
rows = [
{ 'FirstName': 'John', 'LastName': 'Doe' },
{ 'FirstName': 'Ashley', 'LastName': 'Doe' }
];
cols = [
{ 'Desc': 'First Name', 'Data': 'FirstName' },
{ 'Desc': 'Last Name', 'Data': 'LastName' }
];
}
home.html
<table>
<thead>
<tr>
<th *ngFor="let col of cols">{{col.Desc}}</th>
</tr>
</thead>
<tr *ngFor="let row of rows">
<td *ngFor="let col of cols">
{{row.{{col.Data}}}}
</td>
</tr>
</table>
【问题讨论】:
-
永不嵌套
{{}}。
标签: angular expression ngfor