gpt4 book ai didi

javascript - Angular ngShow 没有删除标签样式

转载 作者:行者123 更新时间:2023-11-30 08:37:35 26 4
gpt4 key购买 nike

这是我的js:

(function () {
angular.module("profile.view", [])
.controller("ViewController", ["$scope", function (scope) {
scope.profile = {{ profile_json|raw }};
}]);

angular.module("profileApp", ["profile.view"]);

angular.bootstrap(document, ["profileApp"]);
})();

和我的 html:

<html>
<body>
<div class="loading" ng-if="false">Loading ....</div>
<div ng-controller="ViewController" style="display: none" ng-show="true">
some text
</div>
</body>
</html>

为什么 angular 在加载时不删除“display:none”?

最佳答案

当我们制作 ng-show=false 时,angular 添加(外部)css,如 display: none !important。如果我们设置 ng-show=true,它会删除该 css。

无论我们做出什么改变(ng-show 的值),它总是在 html 中保持 display: none。所以它总是隐藏起来。因为 inline 比内部和外部 css 都具有更高的优先级。因此,为了显示元素,我们必须从元素中删除内联 css。

关于javascript - Angular ngShow 没有删除标签样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30013651/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com