简体   繁体   English

Ionic V6 - 一旦用 ng-if 过滤,离子段在卡片之间显示太多空白

[英]Ionic V6 - ion-segment show too much white space between cards once filtered with ng-if

I have added ion-segment to my page which has a list of cards with different cases.我已将 ion-segment 添加到我的页面,其中包含不同情况下的卡片列表。 If I don't use segment, the space between the cards is very normal.如果我不使用段,卡之间的空间是很正常的。 However, with the use of the segment I have to do the following to filter the data by status variable value.但是,通过使用段,我必须执行以下操作以按状态变量值过滤数据。 It leaves several big gaps between the cards.它在卡片之间留下了几个大的差距。 The height of the gap between the cards is based on the id of the card.卡片之间的间隙高度基于卡片的id。 For example - if the first id for a closed case is 55, second id for a closed case is 20, and third id for a closed case is 17. I see a much larger gap between the case id 55 and 20 than 20 and 17.例如 - 如果关闭案例的第一个 ID 为 55,关闭案例的第二个 ID 为 20,关闭案例的第三个 ID 为 17。我发现案例 ID 55 和 20 之间的差距比 20 和 17 大得多.

<ion-toolbar >
<ion-segment value="open" [(ngModel)]="selectedTabs">
  <ion-segment-button value="open">
    Open
  </ion-segment-button>
  <ion-segment-button value="closed">
    Closed
  </ion-segment-button>
  <ion-segment-button value="underreview">
    Under Review
  </ion-segment-button>
</ion-segment>
</ion-toolbar>
<!-- code for the cards -->
<ion-card *ngFor="let feed of feedData | filter:searchTerm" [routerLink]="[feed.id]">

   <div *ngIf="selectedTabs == 'open'">
  
      <div *ngIf="feed.status == 'Open'">
       
         Show open case data

      </div>

     <div *ngIf="feed.status == 'Closed'">
       
         Show closed case data

     </div>

   ... there are few more status codes but this should give you the idea
   </div>

</ion-card>

离子段

The answer turned out to be a rather simple one, even though it cost me half a day.答案竟然是一个相当简单的答案,尽管它花了我半天的时间。 Need to create another DIV on the top.需要在顶部创建另一个 DIV。

<div *ngFor="let feed of feedData | filter:searchTerm" [routerLink]="[feed.id]">

All other DIVS as needed. 

  <ion-card>
     Card Contents
  </ion-card>

</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM