<div has-class="{ 'open': isOpen, 'closed' : isClosed}"></div>
Is there a way to set the isOpen variable to true on the current scope from the directive as soon as the class that class changes.
This is sort of what i am trying to do with no luck
app.directive('hasClass', [function () {
var definition = {
scope : {
hasClass : "="
},
restrict: 'A',
link: function (scope, element) {
scope.$watch(function () {
return element[0].className;
}, function () {
var items = {};
angular.forEach(scope.hasClass, function (v, k) {
if (element.hasClass(k)) {
scope.hasClass[k] = true;
} else {
scope.hasClass[k] = false;
}
});
});
}
};
return definition;
}]);
Any suggestions are welcome , thank you