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
|
(function() {
'use strict';
// list all rependencies within the page + controler if needed
angular.module('SampleModule', ['SubmitButton','UploadFile'])
.controller('SampleController', function ($http) {
var self = this; // I hate JavaScript
this.status='muted-off';
console.log ("sample controller");
this.MuteOn = function() {
console.log ("Muted");
// send AJAX request to server
var handler = $http.post('/api/dbus/ping', {type:'mute', action: "on"});
handler.success(function(response, errcode, headers, config) {
self.status = 'muted-on';
});
handler.error(function(status, errcode, headers) {
console.log ("Oops /api/dbus/pring err=" + errcode);
self.status = 'muted-error';
});
};
this.MuteOff = function() {
console.log ("UnMuted");
// send AJAX request to server
var handler = $http.post('/api/dbus/ping', {type:'mute', action: "off"});
handler.success(function(response, errcode, headers, config) {
self.status = 'muted-off';
});
handler.error(function(status, errcode, headers) {
console.log ("Oops /api/dbus/ping err=" + errcode);
self.status = 'muted-error';
});
};
});
console.log ("SampleControler Loaded");
})();
|