文章内容

2019/5/26 15:04:52,作 者: 黄兵

ngFor length

在angular中如何获取数组元素的长度?

具体的一些写法如下:

<mat-option *ngFor="let item of optionItem" [value]="item.optionValue">
{{item.optionViewValue?length}}
</mat-option>

或者:

<mat-option *ngFor="let item of optionItem" [value]="item.optionValue">
<div *ngIf="item.optionViewValue"></div>
{{item.optionViewValue.length}}
</mat-option>


参考资料:

1、How to get length of array in template syntax

分享到:

发表评论

评论列表