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', url: '/home',
templateUrl: '/home.html', templateUrl: '/home.html',
controller: 'MainCtrl', 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){ app.factory('arduino', ['$http', function($http, auth){
var o = {}; var o = {
RCs: []
};
o.toggleLight = function ( ) { o.getRCs = function ( ) {
return $http.get('/toggleLight'); return $http.get('/getRCs').success(function(data) {
angular.copy(data, o.RCs);
});
} }
o.irTest = function ( ) { o.irTest = function ( ) {
@ -30,11 +39,7 @@ app.factory('arduino', ['$http', function($http, auth){
app.controller('MainCtrl', ['$scope', 'arduino', function ($scope, arduino){ app.controller('MainCtrl', ['$scope', 'arduino', function ($scope, arduino){
$scope.toggleLight = function(){ $scope.RCs = arduino.RCs;
arduino.toggleLight();
};
$scope.irTest = function(){ $scope.irTest = function(){