Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Filtering a list using starting two letter of an string in array

$
0
0

@khashashin wrote:

How to filter content using ngSwitch and 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

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>