我有一个问题在angular.js的指令/类ng-斗篷或ng-show。

Chrome运行正常,但Firefox使用ng-cloak或ng-show导致元素闪烁。 恕我直言,这是由于将ng-cloak/ng-show转换为style="display: none;",可能Firefox javascript编译器有点慢,所以元素出现一段时间,然后隐藏?

例子:

<ul ng-show="foo != null" ng-cloak>..</ul>

当前回答

尝试了ng-cloak,但仍然眨眼。下面的代码完全清除它们。

<body style="display:none;" ng-style="{'display':'block'}">

其他回答

我们在公司遇到了这个问题,并通过在CSS样式中为那些闪烁的ng-show元素添加“display: none”来解决它。我们根本不需要使用ng-cloak。不像这篇文章中的其他人,我们在Safari中遇到了这个问题,而不是Firefox或Chrome——可能是由于Safari在iOS7中的懒惰重绘错误。

我会用<div ng-cloak>包裹<ul>

由以上讨论可知

[ng-cloak] {
                display: none;
            }

是解决这个问题的完美方法。

尝试了ng-cloak,但仍然眨眼。下面的代码完全清除它们。

<body style="display:none;" ng-style="{'display':'block'}">

ngBind和ngBindTemplate是不需要CSS的替代品:

<div ng-show="foo != null" ng-cloak>{{name}}</div>  <!-- requires CSS -->
<div ng-show="foo != null" ng-bind="name"></div>
<div ng-show="foo != null" ng-bind-template="name = {{name}}"></div>