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

angularjs – ng-if导致链接显示一秒然后消失.如何防止出现

发布时间:2020-12-17 17:54:14 所属栏目:安全 来源:网络整理
导读:ng-if有时会导致我的页面上的链接在加载时显示,然后消失. 该链接根本不应该显示,我假设ng-if语句尚未处理第二个我能够看到它. 有没有办法阻止链接或元素显示? 我也猜测currentClass对象尚未加载,因此ng-if无法评估,但我试图将其默认为隐藏,直到ng-if可以解
ng-if有时会导致我的页面上的链接在加载时显示,然后消失.

该链接根本不应该显示,我假设ng-if语句尚未处理第二个我能够看到它.

有没有办法阻止链接或元素显示?

我也猜测currentClass对象尚未加载,因此ng-if无法评估,但我试图将其默认为隐藏,直到ng-if可以解决.

<span ng-if="isFaculty && !currentClass.courseInformation.IsCustomCourse">
<a ng-href="{{$window.BasePath}}lms/class/{{$stateParams.classid}}/instructorguide/download">
<span class="cec-msword-icon"></span>Download Instructor Guide</a> 
<span>| </span>
</span>

解决方法

使用 ng-cloak.它是这样的:

CSS:

[ng:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak {
  display: none !important;
}

HTML:

<div ng-cloak> ... </div>

在你的情况下,它将是:

<span ng-cloak ng-if="isFaculty && !currentClass.courseInformation.IsCustomCourse">
<a ng-href="{{$window.BasePath}}lms/class/{{$stateParams.classid}}/instructorguide/download">
<span class="cec-msword-icon"></span>Download Instructor Guide</a> 
<span>| </span>
</span>

记得:

The directive can be applied to the element,but the preferred usage is to apply multiple ngCloak directives to small portions of the page to permit progressive rendering of the browser view.

(编辑:李大同)

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

    推荐文章
      热点阅读