gpt4 book ai didi

javascript - 我如何从同一元素中使用 ngFor 项的值?

转载 作者:行者123 更新时间:2023-11-30 11:29:25 26 4
gpt4 key购买 nike

这是我的元素

<div *ngFor="let item of items |xxxx ; let l = count "> <div>

<!--use {{l}} in other element-->

如何获取 {{ l }} 的值,以便在该 div 之外使用它,或者在过滤后直接在 component.ts 中使用它?

最佳答案

将您的模板包装在 <ng-container> 中.像这样:

<ng-container *ngFor="let item of items |xxxx ; let l = count ">
<div ><div>
<!--use {{l}} in other element-->
</ng-container>

关于javascript - 我如何从同一元素中使用 ngFor 项的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46807708/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com