Skip to content

Instantly share code, notes, and snippets.

@sirkitree
Created March 12, 2013 22:38
Show Gist options
  • Save sirkitree/5147740 to your computer and use it in GitHub Desktop.
Save sirkitree/5147740 to your computer and use it in GitHub Desktop.
A CodePen by Jerad Bitner.
<html>
<body ng-app="nodes">
<div class="hero-unit" ng-controller="RecipeCtrl">
<button ng-click="useResource()">$resource request</button>
<ul>
<li ng-repeat="recipe in recipes.list">{{recipe.title}}</li>
</ul>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script>
<script src="http://code.angularjs.org/1.0.5/angular-resource.min.js"></script>
</body>
</html>
var url = "http://copelandia.lulladev.com";
angular
.module('nodes', ['ngResource'])
.controller('RecipeCtrl', function($scope, $resource, $http) {
delete $http.defaults.headers.common['X-Requested-With'];
$scope.useResource = function() {
var Nodes = $resource(
url + '/node.json', {},
{ get: { method: 'JSONP' } }
);
$scope.recipes = Nodes.get({limit: 25});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment