问题描述
我正在使用 angular ui-router.
I'm using angular ui-router.
如果 <div ng-show="total > 0">
当模板被下载并立即显示时,在控制器加载 $scope.total =
之前,我们可以看到 div 的闪烁.
While the template is downloaded and shown immediately we can see a flicker of the div, before the controller loads $scope.total =
.
有人会认为 $scope.total
在开始时是未定义的,因此 div 将被隐藏,但我认为模板尚未解析,它只是显示为原始的.我尝试使用 ng-cloak 但它似乎没有帮助.应该在 angular 启动时使用 Ngcloak,但我使用的是 ui-router,因此 angular 堆栈已经加载.如何在不求助于 ui-router 解析的情况下在模板上隐藏我的元素?
One would think that $scope.total
is undefined in the beginning hence the div would be hidden, but I think the template isn't yet parsed, it's just shown raw. I tried using ng-cloak but it doesn't seem to help. Ngcloak is supposed to be used while angular is booting up, but I'm using ui-router so the angular stack is already loaded. How can I hide my elements on the template without resorting to ui-router resolves?
我使用的是 angular 1.2.8 和 ui-router 0.2.7.
I'm using angular 1.2.8 and ui-router 0.2.7.
推荐答案
请检查这个,似乎可以解决您的问题.
PLease check this one, seems like solution to your problem.
https://stackoverflow.com/a/13276214/801354
这篇关于ng-cloak 对 angular ui-router 在模板解析时隐藏元素没有帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!