[英]Angular show errors only when input not empty and invalid
我正在嘗試切換表單上的錯誤區域,該區域僅在有一些輸入時才觸發,如果用戶尚未開始鍵入錯誤,則所有錯誤都出現會有些愚蠢。
<form name="registerForm">
<input type="email" name="email" ng-model="email" required />
</form>
<span ng-show="registerForm.email.$invalid">
Invalid email.
</span>
鍵入后,此方法工作正常,但如果輸入為空,我希望它不顯示任何錯誤。 我嘗試使用ng-hide="!email.length"
但無法正常工作。
<span ng-show="registerForm.email.$invalid && registerForm.email.$dirty>
嘗試這個:
<span ng-show="registerForm.email.$invalid && email>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.