Angular 在5中的反应形式下使用MatDatePicker
我试图使用matdatepicker输入类型作为angular中被动形式的属性。我有组织价值作为反应性表单组的表单控制 这就是我在html中使用它的方式Angular 在5中的反应形式下使用MatDatePicker,angular,angular-material,angular-reactive-forms,Angular,Angular Material,Angular Reactive Forms,我试图使用matdatepicker输入类型作为angular中被动形式的属性。我有组织价值作为反应性表单组的表单控制 这就是我在html中使用它的方式 <input class="inbox-width" matInput formControlName="organizationValue" [matDatepicker]="organizationValue"> <mat-datepicker-toggle matSuffix [for]="organizationVal
<input class="inbox-width" matInput formControlName="organizationValue" [matDatepicker]="organizationValue">
<mat-datepicker-toggle matSuffix [for]="organizationValue"></mat-datepicker-toggle>
<mat-datepicker #organizationValue></mat-datepicker>
organizationValue属性shownull,但表单中的其他简单输入类型(如textbox、radio、checkbox)会显示正确的值
被动表单属性未绑定到matdatepicker的原因是什么
将其用作嵌套的被动形式,如图所示:
<form *ngIf="companies" [formGroup]="editForm">
<div formArrayName="organizations" *ngFor="let organization of editForm.controls.organizations.controls; let i = index;">
<div formGroupName="{{i}}">
<div class="row row-margin">
<label class="col-sm-3">{{organization.get('organizationTitle').value}}</label>
<div class="col-sm-9">
<input class="inbox-width" matInput formControlName="organizationValue" [matDatepicker]="organizationValue" [ngClass]="organization.get('organizationBorderError').value"
(dateInput)="orgValueChange(i)">
<mat-datepicker-toggle matSuffix [for]="organizationValue"></mat-datepicker-toggle>
<mat-datepicker #organizationValue></mat-datepicker>
</div>
...
{{organization.get('organizationTitle').value}
...
ı将其嵌套在表单中我无法从主表单获取值
<form *ngIf="companies" [formGroup]="editForm">
<div formArrayName="organizations" *ngFor="let organization of editForm.controls.organizations.controls; let i = index;">
<div formGroupName="{{i}}">
<div class="row row-margin">
<label class="col-sm-3">{{organization.get('organizationTitle').value}}</label>
<div class="col-sm-9">
<input class="inbox-width" matInput formControlName="organizationValue" [matDatepicker]="organizationValue" [ngClass]="organization.get('organizationBorderError').value"
(dateInput)="orgValueChange(i)">
<mat-datepicker-toggle matSuffix [for]="organizationValue"></mat-datepicker-toggle>
<mat-datepicker #organizationValue></mat-datepicker>
</div>
...