Refactored handling of form values inside participants component

This commit is contained in:
Erik Tiekstra
2021-03-24 11:04:09 +01:00
committed by Erik Tiekstra
parent f483ae77f2
commit 81ac40ef31
2 changed files with 9 additions and 5 deletions

View File

@@ -7,7 +7,7 @@
leo quis ante porttitor tincidunt. Nam tincidunt imperdiet tortor eu suscipit. Maecenas ut dui est. leo quis ante porttitor tincidunt. Nam tincidunt imperdiet tortor eu suscipit. Maecenas ut dui est.
</p> </p>
<form class="participants__search-wrapper" (ngSubmit)="handleSearchSubmit($event)"> <form class="participants__search-wrapper" (ngSubmit)="handleSearchSubmit()">
<digi-form-input-search <digi-form-input-search
af-label="Sök kunder" af-label="Sök kunder"
af-label-description="Sök på namn eller ärendenummer" af-label-description="Sök på namn eller ärendenummer"

View File

@@ -1,4 +1,5 @@
import { ChangeDetectionStrategy, Component } from '@angular/core'; import { ChangeDetectionStrategy, Component } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
@Component({ @Component({
selector: 'dafa-participants', selector: 'dafa-participants',
@@ -7,14 +8,17 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class ParticipantsComponent { export class ParticipantsComponent {
searchValue = ''; private _searchValue$ = new BehaviorSubject<string>('');
handleSearchSubmit($event: SubmitEvent): void { get searchValue(): string {
return this._searchValue$.getValue();
}
handleSearchSubmit(): void {
console.log(this.searchValue); console.log(this.searchValue);
console.log($event);
} }
handleSearchInput($event: CustomEvent): void { handleSearchInput($event: CustomEvent): void {
this.searchValue = $event.detail.target.value; this._searchValue$.next($event.detail.target.value);
} }
} }