Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS ng-class not applying css styles

Tags:

angularjs

I have a company site that I am developing with AngularJS and I am having some troubles with ng-class

Here is my HTML:

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

CSS:

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

Chrome Inspect Element:

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

Obviously I have tested class="inactive" and it is working as it should, Chrome's view source appears to be showing me something that should be working but it is not being applied.

like image 364
Jonathan Jones Avatar asked Dec 13 '25 17:12

Jonathan Jones


1 Answers

Assuming userRole.admin is a boolean, this should work

<a href="timeEntry.php" ng-class="{ inactive: !userRole.admin }">
    LINK
</a>
like image 162
Mike Robinson Avatar answered Dec 16 '25 23:12

Mike Robinson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!