topics-select.directive.js
1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
(function() {
'use strict';
angular
.module('dialoga')
.directive('topicsSelect', topicsSelect);
/** @ngInject */
function topicsSelect() {
/** @ngInject */
function TopicsSelectController($rootScope, $log) {
$log.debug('TopicsSelectController');
// alias
var vm = this;
// dependencies
vm.$rootScope = $rootScope;
vm.$log = $log;
// initialization
vm.init();
}
TopicsSelectController.prototype.init = function() {
// var vm = this;
};
TopicsSelectController.prototype.selectTopic = function() {
var vm = this;
if (vm.selectedTopic === null) {
vm.$log.debug('Default topic selected.');
return;
}
// send event to all controllers
vm.$rootScope.$broadcast('change-selectedTopic', vm.selectedTopic);
};
var directive = {
restrict: 'E',
templateUrl: 'app/components/topics-select/topics-select.html',
scope: {
topics: '=',
selectedTopic: '='
},
controller: TopicsSelectController,
controllerAs: 'vm',
bindToController: true
};
return directive;
}
})();