Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何在Childcomponent中获取FormControl的初始值_Angular_Angular Reactive Forms_Angular Components_Form Control - Fatal编程技术网

Angular 如何在Childcomponent中获取FormControl的初始值

Angular 如何在Childcomponent中获取FormControl的初始值,angular,angular-reactive-forms,angular-components,form-control,Angular,Angular Reactive Forms,Angular Components,Form Control,如何在自定义组件的ngOnInit方法中获取其初始设置的FormControl值 如果这样设置窗体控件: testControl = new FormControl("abc123"); 然后使用如下属性将其绑定到html中的自定义组件: <app-custom-component [formControl]="testControl"></app-custom-component> 如何在自定义组件的ngOnInit()方法中访问其初始值(“abc123”) 我

如何在自定义组件的ngOnInit方法中获取其初始设置的FormControl值

如果这样设置窗体控件:

testControl = new FormControl("abc123");
然后使用如下属性将其绑定到html中的自定义组件:

<app-custom-component [formControl]="testControl"></app-custom-component>

如何在自定义组件的ngOnInit()方法中访问其初始值(“abc123”)


我已经为自定义组件正确设置了ControlValueAccessor工具。

根据我的理解,您想将值从父组件传递到子组件吗

在子组件中

@输入('variable_in_child_component')变量名称

在父组件中,需要将该值传递给子组件

您有“自定义组件”(普通组件)或“自定义表单控件”(实现ControlValueAccessor的组件)吗?