angular - 使用 ngFor 时删除最后一项之后的分隔线

标签 angular ionic-framework

我正在使用这段代码来显示多个位置:

<div class="location" *ngFor="let item of location_array">
   {{item}} <hr>
</div>

这会导致所有位置由水平线分隔。如何编辑它以获得完全相同的结果,但没有最后一条水平线?

最佳答案

使用 last*ngFor 提供连同 *ngIf在你的 <hr> :

<div class="location" *ngFor="let item of location_array; let lastItem = last;">
   {{item}} <hr *ngIf="!lastItem">
</div>

这是一个StackBlitz Demo .

关于angular - 使用 ngFor 时删除最后一项之后的分隔线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49324884/

相关文章:

ionic-framework - ionic 大项目结构

angularjs - 引用错误: ArticleService is not defined

ionic-framework - ionic 4 + Electron 不起作用

html - ion-infinite-scroll 极少发射

Angular 8 415 不支持的媒体类型,内容类型 'application/json' 不支持 +Spring Boot

angular - 搜索 ionic 5 中事件的替代方案

angular - 您必须取消订阅组件中的 QueryList 吗?

angular - 如何将JS对象数据转换为x-www-form-urlencoded

javascript - 在 Ionic 中得到未定义的输入值

html - 将 Ionic 页面放到网站上