2015-07-01 34 views
0

我正在創建一個Ionic應用程序,當我使用<離子滾動>標記時,我遇到了一些表單驗證問題。這是我的表格:使用離子滾動標籤時的表單驗證錯誤

<form ng-show="!success" name="form" role="form" novalidate ng-submit="register()" show-validation> 
    <div class="list list-inset"> 
     <label class="item item-input"> 
      <input type="text" class="form-control" name="firstName" placeholder="Nome" 
        ng-model="registerAccount.firstName" ng-minlength=1 ng-maxlength=50 required maxlength="50"> 
     </label> 
     <div ng-show="form.firstName.$dirty && form.firstName.$invalid" class="padding-top padding-left assertive"> 
      <p class="help-block" 
       ng-show="form.firstName.$error.required"> 
       some message 
      </p> 
     </div> 
     . 
     . 
     . 
     <label class="item item-input"> 
      <input type="password" class="form-control" name="password" placeholder="Senha" 
        ng-model="registerAccount.password" ng-minlength=5 ng-maxlength=50 required> 
     </label> 
     <div ng-show="form.password.$dirty && form.password.$invalid" class="padding-top padding-left assertive"> 
      <p class="help-block" 
       ng-show="form.password.$error.required"> 
       some message 
      </p> 
     </div> 
     <label class="item item-input"> 
      <input type="password" class="form-control" name="confirmPassword" placeholder="Repita a senha" 
        ng-model="confirmPassword" ng-minlength=5 ng-maxlength=50 required> 
     </label> 
     <div ng-show="form.confirmPassword.$dirty && form.confirmPassword.$invalid" class="padding-top padding-left assertive"> 
      <p class="help-block" 
       ng-show="form.confirmPassword.$error.required"> 
       some message 
      </p> 

      <p class="help-block" 
       ng-show="form.confirmPassword.$error.minlength"> 
       Sua confirmação de senha precisa ter no mínimo 5 caracteres. 
      </p> 

      <p class="help-block" 
       ng-show="form.confirmPassword.$error.maxlength"> 
       Sua confirmação de senha deve ser menor que 50 caracteres. 
      </p> 
     </div> 
    </div> 

    <div class="form-button"> 
     <button type="submit" class="button button-block button-balanced">Criar conta</button> 
     </small> 
    </div> 
</form> 

這種形式的工作正常時,沒有離子的標籤,然而,當我加入離子滾動標記,內部或外部形式標記,驗證失敗,說密碼並確認密碼不同。我應該使用特定的Ionic標籤嗎?這可能是我應該使用的標籤?

+0

我最近遇到了同樣的錯誤。你有沒有找到任何修復? – tryingtolearn

+0

@tryingtolearn我忘記了這個問題......原因是因爲Ionic的元素使用它自己的範圍。稍後我會回答這個問題更多詳情 – brevleq

+0

非常好,謝謝。我很努力地找到關於這個話題的信息,所以你周圍的任何工作都可以建議我們會很感激。 – tryingtolearn

回答

0

問題是因爲一些離子組件使用子範圍,這種範圍"creates an 'isolate' scope that does not prototypically inherit." 我使用推薦的最佳使用方法「」解決了我的問題。 (點)在我的模型。因此,我改變:

<input type="password" ng-model="confirmPassword" required> 

<input type="password" ng-model="something.confirmPassword" required>