在Angular 2中单击时如何将输入值传递给另一个组件?
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.
这里有两个独立的组件。
我的问题是如何在单击按钮时将 component1 的值传递给 anotherComponent。
您可以在 2 个独立组件之间共享数据。可以使用@Input 和@Output 方法。请检查要使用的语法是否正确。请参考 https://www.youtube.com/watch?v=WZzE5o0VsMo .
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.
这里有两个独立的组件。
我的问题是如何在单击按钮时将 component1 的值传递给 anotherComponent。
您可以在 2 个独立组件之间共享数据。可以使用@Input 和@Output 方法。请检查要使用的语法是否正确。请参考 https://www.youtube.com/watch?v=WZzE5o0VsMo .