验证总是在角2 bootstrap4 typehead失败,即使价值选择 [英] Validation always fails in bootstrap4 typehead in angular 2 even if value is selected

查看:277
本文介绍了验证总是在角2 bootstrap4 typehead失败,即使价值选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个表单,我需要添加引导typehead的自动完成功能。

 <输入[(ngModel)] =model.brand[预输入] =model.brandsNG-模式选项={'updateOn':'模糊' }
        (typeaheadOnSelect)=brandOnSelect($事件)(typeaheadNoResults)=brandNoResults($事件)
        [typeaheadOptionField] ='价值'级=表格控ngcontrol =品牌>
        < D​​IV * ngIf =brand.dirty&放大器;&安培;!brand.valid>
            < P * ngIf =brand.errors.required级=TEXT-帮助> {{需要|翻译}}&下; / P>
        < / DIV>

不过,即使我从列表中选择值vaalidations被alws失败。
在这里输入的形象描述

但值模型更新如下

在这里输入的形象描述


解决方案

  ngcontrol =品牌

  ngControl =品牌
   ^

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

解决方案

 ngcontrol="brand"

should be

 ngControl="brand"
   ^

这篇关于验证总是在角2 bootstrap4 typehead失败,即使价值选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆