-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 Lapani
  • 655
  • 10
  • 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
  • 7,120
  • 2
  • 32
  • 36
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
  • 6,242
  • 6
  • 43
  • 58