Validation always fails in bootstrap4 typehead in

2019-07-25 10:01发布

问题:

I am creating a form where i need to add bootstrap typehead for auto complete functionality.

<input [(ngModel)]="model.brand" [typeahead]="model.brands" ng-model-options="{'updateOn': 'blur'}"
        (typeaheadOnSelect)="brandOnSelect($event)" (typeaheadNoResults)="brandNoResults($event)"
        [typeaheadOptionField]="'Value'" class="form-control" ngcontrol="brand" >
        <div *ngIf="brand.dirty && !brand.valid ">
            <p  *ngIf="brand.errors.required" class="text-help">{{ required | translate }}</p>
        </div>

But the vaalidations are alws failed even if i select value from the list. enter image description here

but the values are updated in model as follows

回答1:

 ngcontrol="brand"

should be

 ngControl="brand"
   ^