imsi imsi imsi imsi - 9 months ago 55
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="[]" ng-click="checkarrivee.isMissionSelected(," 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="[]" 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 Source

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')) {