0

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.

3
  • are they child & parent components ? or they both are independent ? Be more specific and let us know what have you tried till now. You can get it on google pretty easily Commented Dec 7, 2018 at 4:47
  • both are independent components. I tried using decorator @input Commented Dec 7, 2018 at 4:55
  • Possible duplicate of How do I share data between components in Angular 2? Commented Dec 7, 2018 at 5:01

1 Answer 1

1

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 .

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

1 Comment

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. how to answer

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.