i399exng1comp/app/board.ctrl.js

29 lines
578 B
JavaScript

(function () {
'use strict';
angular.module('app').controller('BoardCtrl', Ctrl);
Ctrl.$inject = ['board'];
function Ctrl(board) {
var vm = this;
vm.state = {};
init();
function init() {
board.getBoardState().then(function(state) {
vm.state = state
});
}
vm.lightSwitchCallback = function(isOn) {
board.setLight(isOn).then(init)
}
vm.alarmSwitchCallback = function(isOn) {
board.setAlarm(isOn).then(init)
}
}
})();