1
自動完成機能のためにブートストラップ・タイプヘッドを追加する必要があるフォームを作成しています。値が選択されていても、ブートストラップ4の型頭では常に検証が失敗します
<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>
しかし、リストから値を選択しても、警告が表示されません。 は
ここで画像の説明を入力しなく
ありがとうギュンターZöchbauer、 しかしngControlを追加した後でなければなりません= "ブランド" 次のような新しいエラーメッセージが表示されます。 元の例外:NgModelのプロバイダはありません! (Typeahead - > NgModel) http:// localhost:3000/node_modules/angular2/bundles/angular2.dev.js 行23501 –
'Typeahead'は' ngControl'と互換性がありません。 'NgModel'を不適切に使用しているようです。代わりに 'ControlValueAccessor'を使うべきです。 –