I am learning about signal. I created one input text with ngModel, ngModelChanges with signal. My question is why toObservable and toSignal interop methos is not called when input value changed?
This is input with searchQuery() signal used as inside ngModel like below.
<input type="text" [ngModel]="searchQuery()" (ngModelChanges)="searchQuery.set($any($event.target).value)" />
component code is look a like this below.
export class SignalRxjsPractice {
searchService = inject(SearchService);
searchQuery = signal('');
search$: Observable<any[]> = toObservable(this.searchQuery).pipe(
debounceTime(250),
filter((q: string) => q.length > 0),
switchMap((queryString: string) => this.searchService.search(queryString))
);
results = toSignal(this.search$, { initialValue: [''] });
}
My question is when I am typing in input box, why nothing is going to show up for results signal and event service search method is not called. Thanks.
Here is full stackblitz link https://stackblitz.com/edit/stackblitz-starters-x1wzpv?file=src%2Fmain.ts,signal-practices%2Fsignal-rxjs-practice.component.ts