我已经尝试了各种方法,因为已经提出了这个问题,但是对我没有任何帮助,我没有得到我所错过的东西。这是我的代码
content.component.html
<div class="col-12" [ngSwitch]="stateManagement">
<ng-container *ngSwitchCase="'userInfo'" [ngTemplateOutlet]="userInfoTemplate"></ng-container>
</div>
<ng-template #userInfoTemplate>
<form [formGroup]="userInfoTemplate" class="w-100">
<div class="col-12">
<label for="firstname">Firstname</label>
<input type="text" class="form-control inputDesign" id="firstname"
placeholder="Enter Firstname"
formControlName="firstName" name="firstname">
</div>
</form>
</ng-template>
content.component.ts
userInfoTemplate = new FormGroup({
firstName: new FormControl('',[Validators.required, Validators.minLength(1)])
})