get rc switches dynamically from backend

This commit is contained in:
Shannon Sterz 2016-02-17 23:18:40 +01:00
parent ab8991fc89
commit da16d2366b

View file

@ -7,6 +7,11 @@ app.config(['$stateProvider', '$urlRouterProvider',function($stateProvider, $url
url: '/home',
templateUrl: '/home.html',
controller: 'MainCtrl',
resolve: {
postPromise: ['arduino', function(arduino) {
return arduino.getRCs();
}]
}
});
@ -15,10 +20,14 @@ app.config(['$stateProvider', '$urlRouterProvider',function($stateProvider, $url
}]);
app.factory('arduino', ['$http', function($http, auth){
var o = {};
var o = {
RCs: []
};
o.toggleLight = function ( ) {
return $http.get('/toggleLight');
o.getRCs = function ( ) {
return $http.get('/getRCs').success(function(data) {
angular.copy(data, o.RCs);
});
}
o.irTest = function ( ) {
@ -30,12 +39,8 @@ app.factory('arduino', ['$http', function($http, auth){
app.controller('MainCtrl', ['$scope', 'arduino', function ($scope, arduino){
$scope.toggleLight = function(){
arduino.toggleLight();
};
$scope.RCs = arduino.RCs;
$scope.irTest = function(){
arduino.irTest();