Created
November 3, 2016 11:52
-
-
Save LarsBergqvist/81266cd2938af0a7215c4ba7ef006bb2 to your computer and use it in GitHub Desktop.
AngularJS controller for interacting with the outlet REST api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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