JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app="myapp">
Click on child to toggle the parent
<div id="myparent" class='whatewer'>
Parent
<div id="mychild" bazqux ng-click="triggerSmthOnParent()">Child</div>
</div>
</div>
CSS
#myparent {
color: green;
}
#myparent.whatewer {
color:red;
}
JavaScript
angular.module('myapp', []).directive("bazqux", function () {
return {
restrict: "A",
link: function (scope, element, attrs) {
scope.triggerSmthOnParent = function () {
element.parent().toggleClass('whatewer');
}
}
};
});