Remove event attaching from watcher handler.

Events should be attached once, and having event attaching
code within some watcher can cause big memory leaks attaching
same handlers more that one time.
stable
Andrey Antukh 2014-09-03 22:35:59 +02:00
parent 34952e8258
commit 48cf4edbb3
1 changed files with 13 additions and 11 deletions

View File

@ -87,9 +87,6 @@ SprintGraphDirective = ->
link = ($scope, $el, $attrs) -> link = ($scope, $el, $attrs) ->
element = angular.element($el) element = angular.element($el)
$scope.$watch 'stats', (value) ->
if $scope.stats?
redrawChart(element, $scope.stats.days)
$scope.$on "resize", -> $scope.$on "resize", ->
redrawChart(element, $scope.stats.days) redrawChart(element, $scope.stats.days)
@ -100,6 +97,11 @@ SprintGraphDirective = ->
# fix chart overflow # fix chart overflow
timeout(100, -> redrawChart(element, $scope.stats.days)) timeout(100, -> redrawChart(element, $scope.stats.days))
$scope.$watch 'stats', (value) ->
if not $scope.stats?
return
redrawChart(element, $scope.stats.days)
$scope.$on "$destroy", -> $scope.$on "$destroy", ->
$el.off() $el.off()