1

I want to show a list which shows the rows matching the user entered value in the text box. List must keep changing dynamically as user keeps inputting values. that's why I tried using (change) event listener on the input text box. but list changes only after I press 'Enter' button. Here's the code.

<tr>
        <td><input type = "text" [(ngModel)] = "writerSuggest" (change) = "getWriterList($event)" /></td>
</tr>
<tr *ngFor="let writers of writerListShow">
        <td style="cursor: pointer;" (click) = "onWriterClick(writers.name)">{{writers.name}}</td>
</tr>
<tr>
        <td *ngIf = 'writerErr' >No writers with given name</td>
</tr>
Ajeet Eppakayala
  • 1,186
  • 1
  • 10
  • 17

3 Answers3

1

You can use ngmodelChange event.

<td><input type = "text" [ngModel] = "writerSuggest" (ngModelChange) = "getWriterList($event)" /></td>
Suresh Kumar Ariya
  • 9,516
  • 1
  • 18
  • 27
1

Use ng modelChange which detects change of bound variables's value. like

<input type = "text" [(ngModel)] = "writerSuggest" (ngModelChange) = "getWriterList($event)" />
paras shah
  • 861
  • 2
  • 9
  • 23
1

You can try ngModelChange

example

Nithin P.H
  • 671
  • 1
  • 9
  • 29