我试图在Angualr js 2中添加ngControl表单验证到bootstrap 4 typehead控件.
代码如下.
代码如下.
<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 }}</p> </div>
解决方法
您在输入上错过了“name”属性,这是正确使用ngModel所必需的.