gpt4 book ai didi

javascript - AngularJS - 如何定义 ng-bind 的初始延迟

转载 作者:行者123 更新时间:2023-12-01 02:33:08 25 4
gpt4 key购买 nike

我们有一个如下所示的 span 元素:

<span role="link" ng-show="showLink()" ng-bind="textLink"></span>

(正如信息:我们为这个链接设置了一些淡入、淡出动画,这就是为什么我们必须使用 ng-show 而不是 ng-if)

问题是,当页面最初加载时,ng-bind 绑定(bind)文本,仅仅几毫秒我们就看到了链接(闪烁问题),然后 ng-show 和 showLink 最初返回 false,链接将被隐藏。

我们如何实现此设置,以便页面的初始加载根本不显示链接?

PS:我当然可以创建一个函数,通过 setTimeout (300ms)传递文本。但我想看看是否有更好的方法不超时

最佳答案

绑定(bind)ng-cloak属性

The ngCloak directive is used to prevent the AngularJS 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.

<span role="link" ng-show="showLink()" ng-bind="textLink" ng-cloak></span>

More details from AngularJs documentation

关于javascript - AngularJS - 如何定义 ng-bind 的初始延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48163839/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com