在有角度的ng-select节点程序包中,使用“反应式”表单时未显示验证错误

时间:2019-01-08 11:08:09

标签: angular angular6 angular-ngselect

我正在尝试使用ng-select反应形式验证输入字段。由于某些原因,不会为无效输入添加ng-invalid CSS类

<form [formGroup]="heroForm" (ngSubmit)="onSubmit()">
<div class="form-group">
<label for="age">Single select</label>
<ng-select 
    [items]="dropdownList"
    [selectOnTab]="true"
    bindValue="firstname"
    bindLabel="firstname"
    placeholder="Select age"
    formControlName="age">
</ng-select>
<button type="submit" class="btn btn-sm btn-secondary">Submit Form</button>

heroForm: FormGroup;   
constructor(private fb:FormBuilder){}
ngOnInit() {
this.heroForm = this.fb.group({
  age: [null, Validators.required]
});
}

0 个答案:

没有答案