Skip to content

Instantly share code, notes, and snippets.

@romuloctba
Created December 8, 2014 22:54
Show Gist options
  • Save romuloctba/2957b06a5eb5bbfb705d to your computer and use it in GitHub Desktop.
Save romuloctba/2957b06a5eb5bbfb705d to your computer and use it in GitHub Desktop.
Factory AngularJS to consume WP-API REST
app.factory('API', function($resource){
var url = "http://www.urldomeusite.com.br/site/wp-json/";
var API = {
posts: $resource(url+'posts/:id'),
taxonomies: $resource(url+'taxonomies/:taxonomy/terms/:term')
};
return API;
})
.controller('ExampleCtrl', function(API, $scope){
API.posts.query({type: 'meu_type' }, function(data){
$scope.itens = data;
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment