如何将值分配给angular 2中的引用变量?
how to value is assign to reference variable in angular 2?
<ng-container *ngFor="let item of users">
<td *ngIf="item.method == update.business_type">{{item.id}}</td>
</ng-container>
如何 item.id 将值分配给引用 variable.I 已尝试但无效
您需要创建 *ngLet 或 *ngFor 指令,参考 link:
https://medium.com/@AustinMatherne/angular-let-directive-a168d4248138
这是我在创建指令后将变量声明到模板中的方式:
<ng-container *ngFor="let item of users">
<ng-container *ngLet="item.id as ref_var">
<td *ngIf="item.method == update.business_type">{{ref_var}}</td>
</ng-container>
</ng-container>
这也可以使用 *ngVar 指令:
<ng-container *ngFor="let item of users">
<ng-container *ngVar="item.id as ref_var">
<td *ngIf="item.method == update.business_type">{{ref_var}}</td>
</ng-container>
</ng-container>
<ng-container *ngFor="let item of users">
<td *ngIf="item.method == update.business_type">{{item.id}}</td>
</ng-container>
如何 item.id 将值分配给引用 variable.I 已尝试但无效
您需要创建 *ngLet 或 *ngFor 指令,参考 link:
https://medium.com/@AustinMatherne/angular-let-directive-a168d4248138
这是我在创建指令后将变量声明到模板中的方式:
<ng-container *ngFor="let item of users">
<ng-container *ngLet="item.id as ref_var">
<td *ngIf="item.method == update.business_type">{{ref_var}}</td>
</ng-container>
</ng-container>
这也可以使用 *ngVar 指令:
<ng-container *ngFor="let item of users">
<ng-container *ngVar="item.id as ref_var">
<td *ngIf="item.method == update.business_type">{{ref_var}}</td>
</ng-container>
</ng-container>