Comment garder un filtre (keyup) meme en faisant un toggle qui appel une fonctio

Fermé
polak1982 Messages postés 13 Date d'inscription dimanche 24 novembre 2013 Statut Membre Dernière intervention 6 septembre 2021 - 8 juil. 2021 à 16:22
Bonjour à tous,

Quelqu'un peut-il m'aider ?


<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef class="header-cell-name">
<div class="filtre-notification-wrapper">
<label for="filtre-notification" class="filtre-notification-label">Nom</label>
<input id="filtre-notification" type="text" class="form-control smaller filtre-notification" (keyup)="onFilter($event)">
</div>
</th>
<td mat-cell *matCellDef="let row"> {{row.name}} </td>
</ng-container>
<ng-container matColumnDef="notificationTypes">
<th mat-header-cell *matHeaderCellDef> Email </th>
<td mat-cell *matCellDef="let row">
<mat-slide-toggle class="slide-toggle-1" [checked]="row.notificationTypes && row.notificationTypes.includes('EMAIL')" (change)="onMail(row)" title="Être également notifié par e-mail">
</mat-slide-toggle>
</td>
</ng-container>


Component.ts
onMail(row: JournalRow) {
console.log(row);
const mapSubscription = this.subscriptionService.mapSubscription(this.subscriptions);
let subject = this.subscriptionService.findInSubscriptions({ criteria: row.rowId, domain: SUBSCRIPTION_DOMAIN.REVUE }, mapSubscription);
if (subject.notificationTypes && subject.notificationTypes.includes(NotificationType.EMAIL)) {
this.subscriptionService.unsubscribe({ ...subject, notificationTypes: [NotificationType.EMAIL] });
} else {
this.subscriptionService.subscribe({ ...subject, notificationTypes: [NotificationType.EMAIL], notifyBy: NotificationType.EMAIL });
}

}

onFilter(event: Event) {
const value = (event.target as HTMLInputElement).value;
this.dataSource.filter = value;
}



Quand j'effectue une saisie sur le champ de text j'arrive à filtrer à l'aide de ma fonction onFilter. Mais en faisant (un mouvement) un toggle je perd le filtre et tous les resultst s'affichent.
Besoin d'aide please.

ps: Même en touchant au toggle, je souhaite garde mon filtre
Merci
A voir également: