我正在开发角度4.4 +材料beta12自定义组件,但无法弄清楚我的实现中出了什么问题
任务:
问题:
dashboard.component.js
this.CRForm = this.fb.group({
productTeam: [data.productTeam || '']
});Run Code Online (Sandbox Code Playgroud)
在Dashboard.html中
<mat-form-field floatPlaceholder="always" >
<app-mat-custom-form-field #custref formControlName="productTeam" placeholder="P12D" ></app-mat-custom-form-field>
<!--<app-mat-custom-form-field #custref formControlName="productTeam" placeholder="P12D" ngDefaultControl></app-mat-custom-form-field> -->
</mat-form-field>
{{custref.value}} -- gives value eg:[P12DT1H2M] and only if ngDefaultControl
{{CRForm['controls']['productTeam']['value']}} --not giving anyRun Code Online (Sandbox Code Playgroud)
垫定制外形field.ts
import {
Component,
OnInit,
OnDestroy,
Input,
HostBinding,
Optional,
Renderer2,
Self,
forwardRef,
ElementRef
} from '@angular/core';
import {
MatFormFieldControl
} from '@angular/material';
import {
ControlValueAccessor,
FormGroup,
FormBuilder,
NgControl,
NG_VALUE_ACCESSOR
} from …Run Code Online (Sandbox Code Playgroud)