代码如下,页面刚加载的时候ng-show所在的p会冒出来一瞬间,怎么避免呢?
<label class="col-sm-2 control-label">用户名</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="请输入用户名">
<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>
Use
ng-if
to judge orplus
ng-cloak
ng-show, ng-hide are css display and hiding. Try changing the duration of this animation effect to the minimum
Is this form validation? I think it’s better if you try using ng-if
Add ng-cloak to element
ng-cloak
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
Use
ng-if
Add the ng-hide class during initialization or set display: none, and it will be hidden by default
http://www.cnblogs.com/whitew...