The code is as follows. When the page is just loaded, the p where ng-show is located will pop up for a moment. How to avoid it?
<label class="col-sm-2 control-label">username</label>
<p class="col-sm-10">
<input type="text" autocomplete="off" name="username" ng-model="data.username" ng-minlength="5" ng-maxlength="10" ng-required="true" class="form-control" placeholder="請(qǐng)輸入用戶名">
<p ng-show="myform.username.$error.minlength" class="alert alert-danger help-block">
用戶名不能小于5位
</p>
<p ng-show="myform.username.$error.maxlength" class="alert alert-danger help-block">
用戶名不能大于10位
</p>
</p>
ringa_lee
ng-show, ng-hide are css display and hiding. Try changing the duration of this animation effect to the minimum
Use ng-if, show just simply changes the display: none; ng-if removes the entire DOM, so there won’t be the situation you mentioned
Add the ng-hide class during initialization or set display: none, and it will be hidden by default