get rc switches dynamically from backend
This commit is contained in:
parent
ab8991fc89
commit
da16d2366b
1 changed files with 14 additions and 9 deletions
21
nodejs/public/javascripts/angularApp.js
vendored
21
nodejs/public/javascripts/angularApp.js
vendored
|
@ -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,11 +39,7 @@ 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(){
|
||||
|
||||
|
|
Reference in a new issue