2016-04-19 9 views
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> 

しかし、リストから値を選択しても、警告が表示されません。 はenter image description here

ここで画像の説明を入力しなく

enter image description here

答えて

1
ngcontrol="brand" 

を次のように値をモデルに更新さ

ngControl="brand" 
^
+0

ありがとうギュンターZöchbauer、 しかしngControlを追加した後でなければなりません= "ブランド" 次のような新しいエラーメッセージが表示されます。 元の例外:NgModelのプロバイダはありません! (Typeahead - > NgModel) http:// localhost:3000/node_modules/angular2/bundles/angular2.dev.js 行23501 –

+1

'Typeahead'は' ngControl'と互換性がありません。 'NgModel'を不適切に使用しているようです。代わりに 'ControlValueAccessor'を使うべきです。 –

関連する問題