Simon Hunt

GUI --Added cleanup on scope destroy for sample and device views.

Change-Id: Ia1656eb3987f2f896fa7d6d2cec2860495ce36d7
......@@ -22,7 +22,9 @@
'use strict';
angular.module('ovDevice', [])
.controller('OvDeviceCtrl', ['$log', '$scope', '$location', 'RestService',
.controller('OvDeviceCtrl',
['$log', '$scope', '$location', 'RestService',
function ($log, $scope, $location, rs) {
var self = this;
self.deviceData = [];
......@@ -38,6 +40,11 @@
};
$scope.sortCallback();
// Cleanup on destroyed scope
$scope.$on('$destroy', function () {
});
$log.log('OvDeviceCtrl has been created');
}]);
}());
......
......@@ -24,6 +24,9 @@
// injected refs
var $log, tbs, flash;
// configuration
var tbid = 'sample-toolbar';
// internal state
var togFnDiv, radFnP;
......@@ -50,47 +53,57 @@
.style('color', '#369');
}
// define the controller
angular.module('ovSample', ['onosUtil'])
.controller('OvSampleCtrl', ['$log', 'ToolbarService', 'FlashService',
function (_$log_, _tbs_, _flash_) {
var self = this,
toolbar,
rset;
$log = _$log_;
tbs = _tbs_;
flash = _flash_;
self.message = 'Hey there folks!';
togFnDiv = d3.select('#ov-sample')
.append('div')
.text('Look at me!')
.style({
display: 'none',
color: 'rgb(204, 89, 81)',
'font-size': '20pt'
});
radFnP = d3.select('#ov-sample')
.append('p')
.style('font-size', '16pt');
toolbar = tbs.createToolbar('sample');
rset = [
{ gid: 'checkMark', cb: checkFn },
{ gid: 'xMark', cb: xMarkFn },
{ gid: 'bird', cb: birdFn }
];
toolbar.addButton('demo-button', 'crown', btnFn);
toolbar.addToggle('demo-toggle', 'chain', false, togFn);
toolbar.addSeparator();
toolbar.addRadioSet('demo-radio', rset);
toolbar.hide();
checkFn();
$log.log('OvSampleCtrl has been created');
}]);
.controller('OvSampleCtrl',
['$scope', '$log', 'ToolbarService', 'FlashService',
function ($scope, _$log_, _tbs_, _flash_) {
var self = this,
toolbar,
rset;
$log = _$log_;
tbs = _tbs_;
flash = _flash_;
self.message = 'Hey there folks!';
togFnDiv = d3.select('#ov-sample')
.append('div')
.text('Look at me!')
.style({
display: 'none',
color: 'rgb(204, 89, 81)',
'font-size': '20pt'
});
radFnP = d3.select('#ov-sample')
.append('p')
.style('font-size', '16pt');
toolbar = tbs.createToolbar(tbid);
rset = [
{ gid: 'checkMark', cb: checkFn },
{ gid: 'xMark', cb: xMarkFn },
{ gid: 'bird', cb: birdFn }
];
toolbar.addButton('demo-button', 'crown', btnFn);
toolbar.addToggle('demo-toggle', 'chain', false, togFn);
toolbar.addSeparator();
toolbar.addRadioSet('demo-radio', rset);
toolbar.hide();
checkFn();
// Clean up on destroyed scope
$scope.$on('$destroy', function () {
tbs.destroyToolbar(tbid);
});
$log.log('OvSampleCtrl has been created');
}]);
}());
......