Files
openfoodnetwork/app/assets/javascripts/darkswarm/directives/help_modal.js.coffee
Matt-Yorkley 15b6b1271a Remove event handlers in Angular directives on the $destroy event
This is a common source of memory leaks!
2021-08-03 16:20:19 +01:00

14 lines
430 B
CoffeeScript

angular.module('Darkswarm').directive "helpModal", ($modal, $compile, $templateCache)->
restrict: 'A'
scope:
helpText: "@helpModal"
link: (scope, elem, attrs, ctrl)->
compiled = $compile($templateCache.get('help-modal.html'))(scope)
elem.on "click", =>
$modal.open(controller: ctrl, template: compiled, scope: scope, windowClass: 'help-modal small')
scope.$on "$destroy", ->
elem.off("click")