我正在尝试使用反应形式以一种形式上传两个文件。当我尝试以其他形式上传时,没有任何错误,但是现在页面上传后,我就收到了错误-
ERROR Error: formGroup expects a FormGroup instance. Please pass one in. Example: <div [formGroup]="myGroup"> <input formControlName="firstName"> </div> In your class: this.myGroup = new FormGroup({ firstName: new FormControl() });
然后在表单中上传了两个文件(该表单位于模式页面内)并单击Submit按钮后,出现错误-
错误TypeError:无法读取的属性'_syncPendingControls' 未定义
app.component.html
<button (click)="ngxSmartModalService.getModal('mySourceNTargetModal').open()" style="visibility:hidden" id="mySourceNTargetModal">Open myModal</button>
<ngx-smart-modal #myTargetModal identifier="mySourceNTargetModal">
<form (ngSubmit)="sourceNTargetModalButton(addSourceNTargetModalData.value);mySourceNTargetModal.close()" [formGroup]="addTargetModalData">
<!-- <label style="font-size: 1.2em !important;
font-weight: 500 !important;"> Enter Details:</label> -->
<!-- <hr> -->
<div class = "sourceNTargetContainer">
<div class="form-group row">
<label class="col-sm-3 col-form-label" style="font-size: 1.2em !important;
font-weight: 500 !important;">Select Source file</label>
<div class="col-sm-13">
<input id="cin" type="file" (change)="fileTargetChangeEvent($event)" placeholder="Upload Source file" [formControl]="addSourceNTargetModalData.controls['addSourceFile']" multiple/>
<!-- <p style="color: rgb(223, 55, 55);; font-size:15px"
*ngIf="addSourceNTargetModalData.get('addSourceFile').hasError('required') && addSourceNTargetModalData.get('addSourceFile').touched"> -->
</div>
</div>
<br>
<hr>
<br>
<div class="form-group row">
<label class="col-sm-3 col-form-label" style="font-size: 1.2em !important;
font-weight: 500 !important;">Select Target file</label>
<div class="col-sm-13">
<input id="cin" type="file" (change)="fileTargetChangeEvent($event)" placeholder="Upload Target file" [formControl]="addSourceNTargetModalData.controls['addTargetFile']" multiple/>
<!-- <p style="color: rgb(223, 55, 55);; font-size:15px"
*ngIf="addSourceNTargetModalData.get('addTargetFile').hasError('required') && addSourceNTargetModalData.get('addTargetFile').touched"> -->
</div>
</div>
<button type="submit" class="btn btn-secondary" >
<i class="glyphicon glyphicon-icon-shield"></i> Submit</button>
<br>
<br>
</div>
</form>
</ngx-smart-modal>
请帮助我解决错误。