-5

how to clear textbox value from another component.

app.component.html

 <input id="search"
         type="text"
         class="form-control"
         name="criteria"
         placeholder="Search000"
         [(ngModel)]="_criteria"
         (ngModelChange)="criteriaChange()"
          >
Suhag Lapani88
  • 590
  • 7
  • 18

2 Answers2

0

Try this one, Angular 2 changing component variables on another component

This all depends on the relationship of these components and if you can get a handle of this component directly. Ex. in the testing case, I can easily change the property of any component.

windmaomao
  • 5,431
  • 1
  • 26
  • 29
0

Personally, I would just utilize JQuery and on the angular click event, I would just clear out the value; but if you want to use angular.

One way of achieving this is by utilizing @ViewChild

@ViewChild(NameOfComponent) nameOfComponent: NameOfComponent;

this.nameOfComponent.whatEverYouWantToAccess.
Demodave
  • 5,752
  • 5
  • 37
  • 55