我对角度ng-show
指令有问题。我有两个按钮,它们的工作方式就像一个切换按钮。
index.html
<button class="btn btn-primary"
ng-show="!isShow"
ng-click="showDeleted()">
Show deleted items
</button>
<button class="btn btn-primary"
ng-show="isShow"
ng-click="showDeleted()">
Hide deleted items
</button>
myController.js
$scope.showDeleted = function(){
$scope.isShow = !$scope.isShow;
};
当我点击按钮时,一切都很好,但在IE10中,我可以看到隐藏的按钮在闪烁。如果你需要的话,这里有一个plunker。
谢谢!
你试过ng斗篷吗https://docs.angularjs.org/api/ng/directive/ngCloak
ngCloak指令用于防止在加载应用程序时浏览器以原始(未编译)形式短暂显示Angular html模板。使用此指令可以避免html模板显示引起的不希望的闪烁效果
我认为所有有棱角的应用程序(不使用ng-include加载模板)应该使用ng斗篷来防止在angular编译之前隐藏所有模板。