     link = ($scope, $el, $attrs) ->
         timeout(500, -> renderSize($el))
 
+        $scope.$on "$destroy", ->
+            $el.off()
+
     return {link:link}
 
 


KanbanDirective = ($repo, $rootscope) ->
    link = ($scope, $el, $attrs) ->

        tableBodyDom = $el.find(".kanban-table-body")
        tableBodyDom.on "scroll", (event) ->
            target = angular.element(event.currentTarget)
            tableHeaderDom = $el.find(".kanban-table-header .kanban-table-inner")
            tableHeaderDom.css("left", -1 * target.scrollLeft())

    return {link: link}


                    $ctrl = $el.controller()
                    $ctrl.changeUsAssignedTo(us)

        $scope.$on "$destroy", ->
            $el.off()

    return {link: link, require:"ngModel"}

module.directive("tgKanbanUserAvatar", ["$log", KanbanUserDirective])
