Refactored handling of form values inside participants component
This commit is contained in:
committed by
Erik Tiekstra
parent
f483ae77f2
commit
81ac40ef31
@@ -7,7 +7,7 @@
|
||||
leo quis ante porttitor tincidunt. Nam tincidunt imperdiet tortor eu suscipit. Maecenas ut dui est.
|
||||
</p>
|
||||
|
||||
<form class="participants__search-wrapper" (ngSubmit)="handleSearchSubmit($event)">
|
||||
<form class="participants__search-wrapper" (ngSubmit)="handleSearchSubmit()">
|
||||
<digi-form-input-search
|
||||
af-label="Sök kunder"
|
||||
af-label-description="Sök på namn eller ärendenummer"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'dafa-participants',
|
||||
@@ -7,14 +8,17 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
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($event);
|
||||
}
|
||||
|
||||
handleSearchInput($event: CustomEvent): void {
|
||||
this.searchValue = $event.detail.target.value;
|
||||
this._searchValue$.next($event.detail.target.value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user