加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 当使用angular-ui的ui-date datepicker时,Angular

发布时间:2020-12-17 18:09:12 所属栏目:安全 来源:网络整理
导读:我遇到了一个问题,即尽管输入框中有输入,ng-message仍会闪烁“必需”的错误信息.会发生什么事情,它会非常简短地闪烁错误信息:“这个字段是必需的(所有这些都是为了让它更容易看到它闪烁!)”在屏幕上它立即消失之前.对不起,我想让消息在消失之前更容易看到.
我遇到了一个问题,即尽管输入框中有输入,ng-message仍会闪烁“必需”的错误信息.会发生什么事情,它会非常简短地闪烁错误信息:“这个字段是必需的(所有这些都是为了让它更容易看到它闪烁!)”在屏幕上它立即消失之前.对不起,我想让消息在消失之前更容易看到.

这是一个link to my plunker.请输入任何输入,然后单击页面上的其他位置,以便输入字段失去焦点.请注意,因为红色的错误信息会短暂闪烁然后消失.如果您没有快速注意到消息闪烁,则必须重新加载页面才能再次看到它.

为什么会这样?我相信它与ui-date有关,因为我没有ui-date就无法复制问题.

这是代码的片段:

<form name="reportform" ng-submit="process_form()" novalidate >
  <input name="startdate" placeholder="Enter a start date" ui-date ng-model="startdatevalue"  required>
  <ng-messages ng-if='reportform.startdate.$touched' for="reportform.startdate.$error">
    <ng-message when="required" class="error-message">
      THIS FIELD IS REQUIRED (ALL IN CAPS TO MAKE IT EASIER TO SEE IT FLASH BY!)
    </ng-message>
  </ng-messages>
  <button ng-disabled="reportform.$invalid" type="submit">
    Submit Query
  </button>
</form>

谢谢你的帮助.

解决方法

好的,这可能与您显示的特定错误消息相关,也可能不相关,并且仅在使用模板时似乎是一种解决方案.然而,在尝试了一些我遇到的事情后:

ng-cloak

从文档:

The ngCloak directive is used to prevent the Angular html template from being briefly displayed by the browser in its raw (uncompiled) form while your application is loading. Use this directive to avoid the undesirable flicker effect caused by the html template display.

我将此添加到我的每个ngMessages div中,错误闪烁暂时消失,这是有道理的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读