Ibr*_*ady 10 angular2-ngmodel angular2-components angular
我有ParentComponent和ChildComponent,我需要将ParentComponent中的ngModel传递给ChildComponent.
// the below is in ParentComponent template
<child-component [(ngModel)]="valueInParentComponent"></child-component>
Run Code Online (Sandbox Code Playgroud)
如何在ChildComponent中获取ngModel的值并进行操作?
Ami*_*mit 20
您需要ControlValueAccessor在子类中实现.它将您的组件定义为"具有值",可以使用角度方式绑定.
在这里阅读更多相关信息:http://blog.thoughtram.io/angular/2016/07/27/custom-form-controls-in-angular-2.html
| 归档时间: |
|
| 查看次数: |
17145 次 |
| 最近记录: |