需要在 Ionic 中的 ngif 中显示计数器 [英] Need to show counter inside ngif in Ionic

查看:10
本文介绍了需要在 Ionic 中的 ngif 中显示计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ngFor 从 HTML 上的 API 获取数据,但使用 ngIf 进行过滤,请参见下面的 home.html 代码.

I am fetching data from API on HTML using ngFor, but filtering with ngIf, see below home.html code.

{{list.i}} 向我显示数组位置编号 (17,18,19...),但我想显示 1,2,3,4..,我该怎么做?

{{list.i}} is showing me the array position number (17,18,19...), but I want to show 1,2,3,4.., how do I do that?

 <ion-list no-lines *ngFor="let list of display;let i=index;" >
        <ion-item  text-wrap *ngIf="list.ENTUSR='kiran'">
{{list.i}}
    {{list.ENTUSR}}
    {{list.DESCRPITION}}
    </ion-item> 
    </ion-list>

推荐答案

我觉得这里就是你需要的

I think here it is what you need

组件端:

getUsers(users , name){
    return users.filter((user) => user.name === name);
}

模板端:

<div *ngFor="let user of getUsers(users,'Vivek');let i = index;">
  index -> {{ i + 1 }} <br/> 
  id -> {{ user.id}} <br/>
  <hr/>
</div>

工作演示

这篇关于需要在 Ionic 中的 ngif 中显示计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆