I am stuck in search problem. If the user search for something and that is not present in list than it should display error message. But in my case, If I search "panadol" in my list than it will display the list which contains this word and will display the error message on the list which does not contain this word.
Searchbar.html:
<ion-searchbar (keyup)="searching()" placeholder="{{'search' | translate}}" [(ngModel)]="terms"></ion-searchbar>
<div *ngIf="terms == undefined || (terms.length > 1 && !((infectiousdiseasesList.DiseaseCategoryId == 4) && (infectiousdiseasesList.DiseaseName_En.toUpperCase().includes(terms.toUpperCase()) || infectiousdiseasesList.DiseaseName_Ar.includes(terms))) )">
{{'noItemsFound' | translate}}
</div>
<span *ngFor="let infectious of infectiousdiseasesList;let i = index">
<ion-row
*ngIf=" (infectious.DiseaseCategoryId == 4) && (infectious.DiseaseName_En.toLowerCase().includes(terms.toLowerCase()) || infectious.DiseaseName_Ar.includes(terms))"
col-12>
<!-- (infectious.DiseaseCategoryId == 4) && -->
<ion-col col-6>
<ion-item no-lines>
<ion-label *ngIf="this.lang == 'en'">{{infectious.DiseaseName_En}}</ion-label>
<ion-label *ngIf="this.lang == 'ar'">{{infectious.DiseaseName_Ar}}</ion-label>
<ion-checkbox [(ngModel)]="infectious.checked" (ionChange)="selected(infectious,i, $event)" color="danger">
</ion-checkbox>
</ion-item>
</ion-col>
</ion-row>
</span>
Searchbar.ts:
this.storage.get('infectiousDiseases').then(res => {
for(let infectious of res){
if(infectious.DiseaseCategory.Id==4){
this.infectiousdiseasesList.push(infectious);
}
}
});