2014-12-17 6 views
0

ng-show는 양식에 ng-hide 클래스가 있고 필드가 유효하지 않게 될 때마다 클래스를 제거하고 오류 메시지를 표시해야하지만 일부 이유는angle-ng-show는 양식 필드가 유효하지 않을 때 ng-hide 클래스를 제거하지 않습니다.

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
<form id="email-form" name="email-form" ng-controller="loginFormCtrl as ctrl" > 
 
      <div> 
 
       <input ng-model="user.name" ng-minlength="5" ng-maxlength="10" class="w-input username" id="name" type="text" placeholder="Enter your name" name="name" data-name="Name" required> 
 
       <span ng-show="email-form['name'].dirty && email-form['name'].$error.maxlength">too long!</span> 
 
       <span ng-show="email-form.name.dirty && email-form.name.$error.minlength">too short!</span> 
 
      </div> 
 
      <div> 
 
       <input ng-model="user.email" class="w-input" id="email" type="email" placeholder="Enter your email address" name="email" data-name="Email" required> 
 
       <span ng-show="email-form['email'].dirty && email-form.email.$error.required">required</span> 
 
       <span ng-show="email-form.email.dirty && email-form.email.$error.required">not an email</span> 
 
      </div> 
 
      <div class="w-row"> 
 
       <div class="w-col w-col-6 w-col-stack"><a class="button widebutton" ng-click="submit()" href="">Log In</a> 
 
       </div> 
 
       <div class="w-col w-col-6 w-col-stack"><a class="button widebutton" href="" ng-click="go('/createaccount')">Sign Up</a> 
 
       </div> 
 
      </div> 
 
     </form>

+0

'$ 더러운 '이 아니라'더러운 ' – MiTa

+0

그게 다야! 아래 답변과 함께 :) 감사합니다. – Er85

답변

0
이름 = "emailForm"에 양식 이름 이름 = "전자 메일 양식을"변경

작동 나던. documentation 다음에와 같이 사용해야합니다.

<span ng-show="emailForm.email.$dirty && emailForm.email.$error.required">required</span> 
<span ng-show="emailForm.email.$dirty && emailForm.email.$error.email">not an email</span> 

다른 두 개와 동일해야합니다.

+0

고마워요! 지금 그것은 위대한 작품 – Er85

+0

다행 : – Teknotica