imsi imsi imsi imsi - 1 month ago 6
AngularJS Question

delete class item dynamiclly

in my ionic project I'm using a toggle the generated html of this toggle is:

<div class="item-toggle toggle-large ng-valid ng-empty item item-toggle" id="dd" ng-class="checkarrivee.ficheDeMission==undefined ? 'item' : ''" ng-model="checkarrivee.boo[var.id]" ng-click="checkarrivee.isMissionSelected(var.id,checkarrivee.ficheDeMission.id)" toggle-class="toggle-positive"><div ng-transclude=""><span class="ng-binding">Ceintures De Sécurités Passagères</span></div><label class="toggle toggle-positive disable-user-behavior"><input type="checkbox" ng-model="checkarrivee.boo[var.id]" class="ng-pristine ng-untouched ng-valid ng-empty"><div class="track"><div class="handle"></div></div></label></div>


is there a way to check item class dynamiclly, because i dont want the item class to appear in my div, i tried to use ng-class but it didnt work, how i can get div without item class???

Answer

If your code is added via directive, you can make another directive to fix this issue. Here is an example (untested, but simple). Is checks toggle-class attribute to trigger an item class check:

app.directive('toggleClass', function() {
    return {
        restrict: 'A',
        link: function(scope, element, attrs) {
            if (element.hasClass('item')) {
                element.removeClass('item');
            }
        }
    }
});