i399exng1comp/app/board.ctrl.js

29 lines
578 B
JavaScript
Raw Normal View History

2017-04-26 09:23:53 +03:00
(function () {
'use strict';
angular.module('app').controller('BoardCtrl', Ctrl);
2017-05-11 09:20:07 +03:00
Ctrl.$inject = ['board'];
function Ctrl(board) {
2017-04-26 09:23:53 +03:00
var vm = this;
2017-05-11 09:20:07 +03:00
vm.state = {};
init();
function init() {
board.getBoardState().then(function(state) {
vm.state = state
});
}
2017-04-26 09:23:53 +03:00
2017-05-11 09:20:07 +03:00
vm.lightSwitchCallback = function(isOn) {
board.setLight(isOn).then(init)
}
2017-04-26 09:23:53 +03:00
2017-05-11 09:20:07 +03:00
vm.alarmSwitchCallback = function(isOn) {
board.setAlarm(isOn).then(init)
2017-04-26 09:23:53 +03:00
}
}
})();