GUI --Added cleanup on scope destroy for sample and device views.
Change-Id: Ia1656eb3987f2f896fa7d6d2cec2860495ce36d7
Showing
2 changed files
with
24 additions
and
4 deletions
... | @@ -22,7 +22,9 @@ | ... | @@ -22,7 +22,9 @@ |
22 | 'use strict'; | 22 | 'use strict'; |
23 | 23 | ||
24 | angular.module('ovDevice', []) | 24 | angular.module('ovDevice', []) |
25 | - .controller('OvDeviceCtrl', ['$log', '$scope', '$location', 'RestService', | 25 | + .controller('OvDeviceCtrl', |
26 | + ['$log', '$scope', '$location', 'RestService', | ||
27 | + | ||
26 | function ($log, $scope, $location, rs) { | 28 | function ($log, $scope, $location, rs) { |
27 | var self = this; | 29 | var self = this; |
28 | self.deviceData = []; | 30 | self.deviceData = []; |
... | @@ -38,6 +40,11 @@ | ... | @@ -38,6 +40,11 @@ |
38 | }; | 40 | }; |
39 | $scope.sortCallback(); | 41 | $scope.sortCallback(); |
40 | 42 | ||
43 | + // Cleanup on destroyed scope | ||
44 | + $scope.$on('$destroy', function () { | ||
45 | + | ||
46 | + }); | ||
47 | + | ||
41 | $log.log('OvDeviceCtrl has been created'); | 48 | $log.log('OvDeviceCtrl has been created'); |
42 | }]); | 49 | }]); |
43 | }()); | 50 | }()); | ... | ... |
... | @@ -24,6 +24,9 @@ | ... | @@ -24,6 +24,9 @@ |
24 | // injected refs | 24 | // injected refs |
25 | var $log, tbs, flash; | 25 | var $log, tbs, flash; |
26 | 26 | ||
27 | + // configuration | ||
28 | + var tbid = 'sample-toolbar'; | ||
29 | + | ||
27 | // internal state | 30 | // internal state |
28 | var togFnDiv, radFnP; | 31 | var togFnDiv, radFnP; |
29 | 32 | ||
... | @@ -50,9 +53,14 @@ | ... | @@ -50,9 +53,14 @@ |
50 | .style('color', '#369'); | 53 | .style('color', '#369'); |
51 | } | 54 | } |
52 | 55 | ||
56 | + | ||
57 | + // define the controller | ||
58 | + | ||
53 | angular.module('ovSample', ['onosUtil']) | 59 | angular.module('ovSample', ['onosUtil']) |
54 | - .controller('OvSampleCtrl', ['$log', 'ToolbarService', 'FlashService', | 60 | + .controller('OvSampleCtrl', |
55 | - function (_$log_, _tbs_, _flash_) { | 61 | + ['$scope', '$log', 'ToolbarService', 'FlashService', |
62 | + | ||
63 | + function ($scope, _$log_, _tbs_, _flash_) { | ||
56 | var self = this, | 64 | var self = this, |
57 | toolbar, | 65 | toolbar, |
58 | rset; | 66 | rset; |
... | @@ -76,7 +84,7 @@ | ... | @@ -76,7 +84,7 @@ |
76 | .append('p') | 84 | .append('p') |
77 | .style('font-size', '16pt'); | 85 | .style('font-size', '16pt'); |
78 | 86 | ||
79 | - toolbar = tbs.createToolbar('sample'); | 87 | + toolbar = tbs.createToolbar(tbid); |
80 | rset = [ | 88 | rset = [ |
81 | { gid: 'checkMark', cb: checkFn }, | 89 | { gid: 'checkMark', cb: checkFn }, |
82 | { gid: 'xMark', cb: xMarkFn }, | 90 | { gid: 'xMark', cb: xMarkFn }, |
... | @@ -91,6 +99,11 @@ | ... | @@ -91,6 +99,11 @@ |
91 | 99 | ||
92 | checkFn(); | 100 | checkFn(); |
93 | 101 | ||
102 | + // Clean up on destroyed scope | ||
103 | + $scope.$on('$destroy', function () { | ||
104 | + tbs.destroyToolbar(tbid); | ||
105 | + }); | ||
106 | + | ||
94 | $log.log('OvSampleCtrl has been created'); | 107 | $log.log('OvSampleCtrl has been created'); |
95 | }]); | 108 | }]); |
96 | }()); | 109 | }()); | ... | ... |
-
Please register or login to post a comment