gpt4 book ai didi

AngularJS ng-class 不应用 css 样式

转载 作者:行者123 更新时间:2023-12-01 09:59:32 25 4
gpt4 key购买 nike

我有一个使用 AngularJS 开发的公司网站,但我在使用 ng-class

时遇到了一些问题

这是我的 HTML:

<a href="timeEntry.php" ng-class="{{(userRole.admin) ? '' : 'inactive'}}">
LINK
</a>

CSS:

.inactive {
pointer-events : none;
cursor : default;
}

Chrome 检查元素:

<a href="timeEntry.php" ng-class="inactive">
LINK
</a>

显然我已经测试了 class="inactive" 并且它正常工作,Chrome 的 View 源似乎向我展示了一些应该工作但没有被应用的东西。

最佳答案

假设 userRole.admin 是一个 bool 值,这应该可行

<a href="timeEntry.php" ng-class="{ inactive: !userRole.admin }">
LINK
</a>

关于AngularJS ng-class 不应用 css 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18322129/

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