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.
|
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"
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user