I have a div that is usually hidden:
我有一个通常隐藏的div:
<div id="errorDiv" x-ng-show="errorOccured">
{{errorStatus}}: {{errorMessage}}
</div>
when I load the page, I see it for a short second, which I don't want. So I tried hiding it at start:
当我加载页面时,我会在短时间内看到它,这是我不想要的。所以我试着在开始时隐藏它:
<div id="errorDiv" x-ng-show="errorOccured" class="ng-hide">
{{errorStatus}}: {{errorMessage}}
</div>
but that didn't work :-( Is there any good way to hide a div at the time of page loading?
但这不起作用:-(有没有什么好方法可以在页面加载时隐藏div?
2 个解决方案
#2
1
If you don't want to use ngCloak
, there's always ngBindTempalate
. Then your html would look like this:
如果你不想使用ngCloak,那么总是有ngBindTempalate。然后你的HTML看起来像这样:
<div id="errorDiv" ng-show="errorOccured" ng-bind-template="{{errorStatus}} : {{errorMessage}}"></div>
Documentation here:
这里的文件:
https://docs.angularjs.org/api/ng/directive/ngBindTemplate
https://docs.angularjs.org/api/ng/directive/ngBindTemplate
It won't hide the div, but it won't populate it with ugly curly braces either.
它不会隐藏div,但它也不会用丑陋的花括号填充它。
#1
#2
1
If you don't want to use ngCloak
, there's always ngBindTempalate
. Then your html would look like this:
如果你不想使用ngCloak,那么总是有ngBindTempalate。然后你的HTML看起来像这样:
<div id="errorDiv" ng-show="errorOccured" ng-bind-template="{{errorStatus}} : {{errorMessage}}"></div>
Documentation here:
这里的文件:
https://docs.angularjs.org/api/ng/directive/ngBindTemplate
https://docs.angularjs.org/api/ng/directive/ngBindTemplate
It won't hide the div, but it won't populate it with ugly curly braces either.
它不会隐藏div,但它也不会用丑陋的花括号填充它。