执行前不显示 AngularJS 代码
Don't display AngularJS code before execution
当我重新加载页面时,我的 AngularJS 代码正在显示
问题: 如果我的网速较慢或页面未完全重新加载,代码不应显示。它应该只显示结果。
请帮我找到最好的解决方案。
ng-cloak
用法相同。在这里阅读 https://docs.angularjs.org/api/ng/directive/ngCloak
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>{{cat1.Title | limitTo:18}}</div>
喜欢这个:
<div ng-bind="cat1.Title | limitTo:18"></div>
使用 ngCloak 是正确的方法。
确保也添加 CSS,基于此 post:Angularjs - ng-cloak/ng-show elements blink
/*
Allow angular.js to be loaded in body, hiding cloaked elements until
templates compile. The !important is important given that there may be
other selectors that are more specific or come later and might alter display.
*/
[ng\:cloak], [ng-cloak], .ng-cloak {
display: none !important;
}
当我重新加载页面时,我的 AngularJS 代码正在显示
问题: 如果我的网速较慢或页面未完全重新加载,代码不应显示。它应该只显示结果。
请帮我找到最好的解决方案。
ng-cloak
用法相同。在这里阅读 https://docs.angularjs.org/api/ng/directive/ngCloak
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>{{cat1.Title | limitTo:18}}</div>
喜欢这个:
<div ng-bind="cat1.Title | limitTo:18"></div>
使用 ngCloak 是正确的方法。
确保也添加 CSS,基于此 post:Angularjs - ng-cloak/ng-show elements blink
/*
Allow angular.js to be loaded in body, hiding cloaked elements until
templates compile. The !important is important given that there may be
other selectors that are more specific or come later and might alter display.
*/
[ng\:cloak], [ng-cloak], .ng-cloak {
display: none !important;
}