问题
I have two segments on my page that switches the selection list on the page upon toggling them
<ion-segment [(ngModel)]="changeCart" color="primary">
<ion-segment-button value="includeSeg" (ionSelect)="onSetEnclude()">
<ion-icon name="add"></ion-icon>
</ion-segment-button>
<ion-segment-button value="excludeSeg" (ionSelect)="onSetExclude()">
<ion-icon name="remove"></ion-icon>
</ion-segment-button>
</ion-segment>
Under this segment there were two respective search tool bar which will be displayed to the based on the active segment. When the user manually types something, the list is displayed under this and the user able to select one from it. But then after, if the user toggles the segment, the list displayed on the screen until the user starts typing in on the corresponding search element. Then the incorrect list disappears and the right list appears
When the user toggles the segment, Is there a way to either clean the list or hide the ion-list.
回答1:
You could make those lists show or hide depending on that ngModel value. You could do this by adding a class to the ion-input.
<ion-input [class.hideList]="changeChart!=='includeSeg'">
...
and in the css:
.hideList {
.theListsClassName{
display: none;
}
}
来源:https://stackoverflow.com/questions/52571622/ionic-autocomplete-option-in-search-text-not-disappearing-after-selection