Created
May 15, 2016 12:24
-
-
Save LarsBergqvist/06304a1f09a2c70d196c9c343bab6c64 to your computer and use it in GitHub Desktop.
AngularJS controller for rc outlet web app
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(id,action) { | |
$http.put("api/outlets/"+id, { 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