SmartIT_Extensions/BMC/smart-it-full-helix/scripts/app/common/toggle-item-directive.js

25 lines
816 B
JavaScript

"use strict";
(function () {
'use strict';
angular.module('myitsmApp')
.directive('toggleItem', [function () {
return {
restrict: 'A',
scope: {
toggleItem: '@'
},
link: function (scope, element) {
function clickHandler() {
element.parents('.' + scope.toggleItem).toggleClass('opened');
}
element.on('click', clickHandler);
scope.$on("$destroy", function () {
console.log("toggleItem: unbind events");
element.off('click', clickHandler);
element.off();
});
}
};
}]);
}());