<%- include('../../common/partial/header.unfinished.txt') %> * @ngdoc directive * @name <%= appNameCamel %>.directive:<%= directiveNameKebab %><% if (parent) { %> * @requires <%= parent %><% } %> * @scope * @restrict <%= restrict %> * @replace <%= replace %> * @transclude <%= transclude %> * * @description * * [Scope params, one-way binding] * * [Scope params, two-way binding] * * [Attrs params] * */ (function (angular) { 'use strict'; angular .module('<%= appNameCamel %>') .directive('<%= directiveNameCamel %>', <%= directiveNameCamel %>); <%= directiveNameCamel %>.$inject = [ '_' ]; function <%= directiveNameCamel %>(_) { return { link,<% if (parent) { %> require : '^^<%= parent %>',<% } %> restrict : '<%= restrict %>', replace : <%= replace %>, transclude : <%= transclude %>, scope : {}, templateUrl : '<%= templateUrl %>', bindToController: true, controller : '<%= controllerName %>', controllerAs : 'vm' }; function link(scope, element, attrs) { const methods = { init, destroy }; methods.init(); function init() { // Destroy listeners element.on('$destroy', methods.destroy); scope.vm.data.listeners.push(scope.$on('$destroy', methods.destroy)); } function destroy() { element.off('$destroy', methods.destroy); _.forEach(scope.vm.data.listeners, $listener => { $listener(); }); } } } })(window.angular);