2016-07-28 99 views
0

在窗體中有選擇框,我嘗試使驗證,但不工作相同的輸入類型文本之前我做的。我做錯了什麼?AngularJS驗證選擇框

例如

<div class="form-group"> 
           <label class="control-label col-sm-3">Email<sup>*</sup></label> 

             <div class="col-sm-6"> 

              <div class="input-icon-right"> 
               <i class="fa fa-envelope"></i> 
               <input class="form-control" placeholder="[email protected]" type="email" ng-model="patient.email" name="email" required> 
               <p ng-show="myForm.email.$error.required" style="color:red" ng-if="myForm.email.$touched">Add your email</p> 

              </div> 

             </div> 
          </div> 

此代碼的工作好,並顯示錯誤消息時字段爲空。

並且此代碼與選擇框無法正常工作,每次選擇不空,但有選擇 - 選擇 - ,如何我可以顯示錯誤時,沒有另一個chice。

<div class="form-group"> 
           <label class="col-sm-3 control-label">{{getWord('Gender')}}<sup>*</sup></label> 
           <div class="col-sm-6"> 
            <select ui-select2 ng-model="patient.gender" 
              data-placeholder="Tên Cơ Sở" 
              ng-change="changeGender()" 
              style="width: 100%;" requied name="gender"> 
             <option value="">-{{getWord('Select')}}-</option> 
             <option ng-repeat="item in genders" value="{{item.name}}"> 
              {{getWord(item.name)}} 
             </option> 
            </select> 
            <p ng-show="myForm.gender.$error.required" style="color:red" ng-if="myForm.gender.$touched">Please choice gender</p> 
           </div> 
          </div> 
+1

您需要的拼寫錯誤? 「