使用 ng-class 删除有条件添加的 class

Remove a class added conditionally using ng-class

我使用 ng-class 根据条件添加 class another-class 。是否可以使用 ng-class 删除 another-class 当条件是不是遇到了?现在,即使不满足条件,class another-class 也会保留在元素中!

<div ng-hide="ok.isTrue" ng-class = "'{{ok.Id}}' === '{{notok.Id}}' ? 'another-class': '' ;" class="some-class">

您可以为此使用不同的 ng-class 语法,尤其是地图语法:

ng-class="{'another-class': ok.Id === notok.Id}"