gpt4 book ai didi

angularjs - 如何在页面加载期间隐藏 AngularJS 中的表达式?

转载 作者:行者123 更新时间:2023-12-02 04:05:13 25 4
gpt4 key购买 nike

例如,我有以下代码:

div {{count}}

然后在我的 JavaScript 中,它将被替换为一个值。

但是,不知何故,如果我刷新页面,{{count}} 将最初显示在页面中,直到页面完全加载。

如何在页面加载期间隐藏它?

最佳答案

您有 2 个解决方案

第一

您可以使用ng-bind

The ngBind attribute tells Angular to replace the text content of the specified HTML element with the value of a given expression, and to update the text content when the value of that expression changes.

<div ng-bind="count"></div>

第二

您可以使用ng-cloack

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.

<div ng-cloack>{{count}}</div>

关于angularjs - 如何在页面加载期间隐藏 AngularJS 中的表达式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39846115/

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