This repository has been archived on 2024-01-30. You can view files and clone it, but cannot push or open issues or pull requests.
trev/nodejs/public/javascripts/angularApp.js

50 lines
No EOL
1 KiB
JavaScript

var app = angular.module('autome', ['ui.router']);
app.config(['$stateProvider', '$urlRouterProvider',function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('home', {
url: '/home',
templateUrl: '/home.html',
controller: 'MainCtrl',
resolve: {
postPromise: ['arduino', function(arduino) {
return arduino.getRCs();
}]
}
});
$urlRouterProvider.otherwise('home');
}]);
app.factory('arduino', ['$http', function($http, auth){
var o = {
RCs: []
};
o.getRCs = function ( ) {
return $http.get('/getRCs').success(function(data) {
angular.copy(data, o.RCs);
});
}
o.irTest = function ( ) {
return $http.get('/irTest');
}
return o;
}]);
app.controller('MainCtrl', ['$scope', 'arduino', function ($scope, arduino){
$scope.RCs = arduino.RCs;
$scope.irTest = function(){
arduino.irTest();
};
}]);