search

Home  >  Q&A  >  body text

angular.js - ng-show will be displayed for a moment when the page is loaded. How to avoid it?

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="请输入用户名">
                <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_leeringa_lee2783 days ago767

reply all(9)I'll reply

  • PHPz

    PHPz2017-05-15 17:13:36

    • Use ng-if to judge or

    • plus ng-cloak

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-15 17:13:36

    ng-show, ng-hide are css display and hiding. Try changing the duration of this animation effect to the minimum

    reply
    0
  • 高洛峰

    高洛峰2017-05-15 17:13:36

    Is this form validation? I think it’s better if you try using ng-if

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-15 17:13:36

    Add ng-cloak to element

    reply
    0
  • PHP中文网

    PHP中文网2017-05-15 17:13:36

    ng-cloak

    reply
    0
  • 高洛峰

    高洛峰2017-05-15 17:13:36

    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

    reply
    0
  • 高洛峰

    高洛峰2017-05-15 17:13:36

    Use ng-if

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-15 17:13:36

    Add the ng-hide class during initialization or set display: none, and it will be hidden by default

    reply
    0
  • 怪我咯

    怪我咯2017-05-15 17:13:36

    http://www.cnblogs.com/whitew...

    reply
    0
  • Cancelreply