Manjeshwar
Manjeshwar

Reputation: 105

how to pass the input value to another component when clicked in Angular 2?

component1.html

<input type="text" value="some text">
<button>next</button>

anotherComponent.html

<input type="text">//value of component1 should be shown here when the button is clicked.

There are two independent components here.

My question is how to pass value of component1 to anotherComponent when the button is clicked.

Upvotes: 0

Views: 1517

Answers (1)

Vaishnavi Baliga
Vaishnavi Baliga

Reputation: 26

You can share data between 2 independent components. @Input and @Output method can be used. Please check for the correct syntax to be used. Please refer https://www.youtube.com/watch?v=WZzE5o0VsMo .

Upvotes: 1

Related Questions