I wont to filter words depending on chosen segment value e.g segments have values like
| aa | ab | ac | ad | ae | af | … etc. And click on one of the segment should show relevant words e.g click on | ab | should show only words that begin with “ad” and so on.
My current method to solve this (which is not working ofc. )
// letter.page.html
<ion-segment scrollable mode="md" (ionChange)="filterWords($event)" [(ngModel)]="filter.query">
<ion-segment-button mode="md" class="ce-sm-segment" value="all">
<ion-icon name="infinite"></ion-icon>
</ion-segment-button>
<ion-segment-button mode="md" class="ce-sm-segment" value="starred">
<ion-icon name="star-outline"></ion-icon>
</ion-segment-button>
<ion-segment-button mode="md" *ngFor="let ltr of twoLettersList" class="ion-text-lowercase" value={{ltr}}>
{{ltr}}
</ion-segment-button>
</ion-segment>
<div [ngSwitch]="filter.q" *ngFor="let word of (words ? words : [])">
<ion-item *ngSwitchCase="filter.q">
<ion-label>
{{word.word_chechen}}
</ion-label>
</ion-item>
</div>
//letter.page.ts
filter = {
query: 'all',
q: 'all' as any
};
filterWords($event) {
console.log('All: ', $event.detail.value);
console.log('Query: ', this.filter.query);
this.filter.q = new RegExp('^' + this.filter.query + '\\w+');
console.log('Filtered: ', this.filter.q);
}

