get rc switches dynamically from backend

This commit is contained in:
Stefan Sterz 2016-02-17 23:18:40 +01:00
parent ab8991fc89
commit da16d2366b
1 changed files with 14 additions and 9 deletions

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();