我有以下模板:
<div *ngFor="let item of myArray | customPipe1 | customPipe2; let l = length">
Here is the length of my ngFor : {{l}}
</div>
不幸的是,ngFor 中不存在长度。如何解决此问题以使 ngFor 中的长度可用?
另一种解决方案可能如下
<div *ngFor="let item of myArray | customPipe1 | customPipe2; let l = count">
Here is the length of my ngFor : {{l}}
</div>
笨蛋的例子 https://plnkr.co/edit/jWD9oVtA3CQM6QdcfFVS?p=preview
See also
- https://github.com/angular/angular/blob/master/packages/common/src/directives/ng_for_of.ts#L15-L17 https://github.com/angular/angular/blob/master/packages/common/src/directives/ng_for_of.ts#L15-L17
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)