0
我有一个关于动态组件渲染的问题。我有一个Parent component
和一个Child component
。在child component template
有文本字段,用户可以输入值。在那里,我也有一个提交按钮,提交按钮的功能在Parent Component
中声明。从子组件获取数据到父组件
我现在的问题是当我点击提交按钮时,我无法获得用户在Child Component Template
中输入的值。我必须从child
获取最新数据到parent
。我真的不知道如何解决这个问题,我看过@output
,但仍然阅读关于它的教程。你有什么想法如何实现这一目标?
https://angular.io/docs/ts/latest/cookbook/component-communication.html –
您可以定义Reactive窗体并将其作为@Input传递给子组件,然后在提交时将父窗体中的所有数据零件。 https://angular.io/docs/ts/latest/cookbook/dynamic-form.html – Nikolai