45 lines
No EOL
849 B
JavaScript
45 lines
No EOL
849 B
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',
|
|
|
|
});
|
|
|
|
$urlRouterProvider.otherwise('home');
|
|
|
|
}]);
|
|
|
|
app.factory('arduino', ['$http', function($http, auth){
|
|
var o = {};
|
|
|
|
o.toggleLight = function ( ) {
|
|
return $http.get('/toggleLight');
|
|
}
|
|
|
|
o.irTest = function ( ) {
|
|
return $http.get('/irTest');
|
|
}
|
|
|
|
return o;
|
|
}]);
|
|
|
|
app.controller('MainCtrl', ['$scope', 'arduino', function ($scope, arduino){
|
|
|
|
$scope.toggleLight = function(){
|
|
|
|
arduino.toggleLight();
|
|
|
|
};
|
|
|
|
$scope.irTest = function(){
|
|
|
|
arduino.irTest();
|
|
|
|
};
|
|
|
|
}]); |