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.

Manjeshwar
  • 105
  • 3
  • 13
  • 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 – Shashank Vivek Dec 07 '18 at 04:47
  • both are independent components. I tried using decorator @input – Manjeshwar Dec 07 '18 at 04:55
  • Possible duplicate of [How do I share data between components in Angular 2?](https://stackoverflow.com/questions/31026886/how-do-i-share-data-between-components-in-angular-2) – Amit Chigadani Dec 07 '18 at 05:01

1 Answers1

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 .

  • 3
    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](https://stackoverflow.com/help/how-to-answer) – Agilanbu Dec 07 '18 at 05:18