-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()"
          >
2

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.