我有一个使用 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/