Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cliffmeyers
Last active December 22, 2015 00:00
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 cliffmeyers/8b673b37ae3b71dafb42 to your computer and use it in GitHub Desktop.
Save cliffmeyers/8b673b37ae3b71dafb42 to your computer and use it in GitHub Desktop.
Controller to fetch very specific types of donuts.
function DonutController2($scope, $http) {
// called from the partial on button click
$scope.fetchDonuts = function() {
// construct url based on values bound to form elements
var url = '/api/donuts/list?size=' + $scope.size +
'&filling=' + $scope.filling +
'&glaze=' + $scope.glaze +
'&hole=' + $scope.hasHole ? 1 : 0;
// feed me
$http.get(url)
.then(function(response) {
$scope.donuts = response.data.results;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment