Created
December 8, 2014 22:54
-
-
Save romuloctba/2957b06a5eb5bbfb705d to your computer and use it in GitHub Desktop.
Factory AngularJS to consume WP-API REST
This file contains hidden or 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
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