Skip to content

Instantly share code, notes, and snippets.

@yoren
Last active June 12, 2019 08:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoren/64db51f26341939214c6 to your computer and use it in GitHub Desktop.
Save yoren/64db51f26341939214c6 to your computer and use it in GitHub Desktop.
Display WordPress posts with AngularJS and JSON API
<ul>
<li ng-repeat="post in posts">
<a href="{{post.ID}}">
{{post.title}}
</a>
</li>
</ul>
angular.module('app', ['ngRoute'])
.config(function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when('/', {
templateUrl: myLocalized.partials + 'main.html',
controller: 'Main'
});
})
.controller('Main', function($scope, $http, $routeParams) {
$http.get('wp-json/posts/').success(function(res){
$scope.posts = res;
});
});
@yoren
Copy link
Author

yoren commented Nov 6, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment