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