@khashashin wrote:
How to filter content using
ngSwitchand taking only first two letters of a string? I have tried to solve it myself some how but I’m doing it wrong way I guess.<ion-segment scrollable mode="md" [(ngModel)]="filter"> <ion-segment-button mode="md" class="ce-sm-segment" value="all" (click)="showSelectedLetterPopup('all')"> <ion-icon name="medical"></ion-icon> </ion-segment-button> <ion-segment-button mode="md" class="ce-sm-segment" value="starred" (click)="showSelectedLetterPopup('☆')"> <ion-icon name="star-outline"></ion-icon> </ion-segment-button> <ion-segment-button mode="md" *ngFor="let ltr of twoLetterArray" class="ion-text-lowercase" value={{ltr}} (click)="showSelectedLetterPopup(ltr)"> {{ltr}} </ion-segment-button> </ion-segment> <div [ngSwitch]="word.substring(0, 2)" *ngFor="let word of (words ? words : [])"> <ion-item *ngSwitchCase="'filter'" routerLink="/tabs/dictionary/word-detail/{{word.id}}"> <ion-label> {{word.word_chechen}} </ion-label> </ion-item> </div>I have following objects in the page component:
twoLetterArray = ['aa', 'ab', 'ac', 'ad', 'ae'] words = ['Aachen', 'Abaco', 'acetone', 'adaptation', 'Aegeus']
Posts: 1
Participants: 1