Skip to content

Instantly share code, notes, and snippets.

@LarsBergqvist
Created November 3, 2016 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LarsBergqvist/81266cd2938af0a7215c4ba7ef006bb2 to your computer and use it in GitHub Desktop.
Save LarsBergqvist/81266cd2938af0a7215c4ba7ef006bb2 to your computer and use it in GitHub Desktop.
AngularJS controller for interacting with the outlet REST api
var myApp = angular.module('myApp', []);
myApp.controller('OutletController', ['$scope', '$http', function($scope, $http) {
$scope.header = 'Outlets';
var getOutletInfo = function() {
$http.get("api/outlets").then(function(response) {
var outlets = response.data.outlets;
$scope.outlets = outlets;
}, function(error) {}
);
};
$scope.pressButton = function(groupNumber,buttonNumber,action) {
$http.put("api/outlets/"+groupNumber+"/"+buttonNumber, { state : action}).then(function(response) {
}, function(error) {}
);
}
getOutletInfo();
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment