Andrew's Blog

Angular with WP API

Posted on:

I wanted to be able to use the WP API to show my latest posts on an external site, and here's how I did it using Angular. You need:

  • A WordPress site with the latest version of the WP API Plugin (I am using 2.0 Beta 4.0) from Github (use develop branch)
  • A copy of Angular


	Latest 10 Posts from


var app = angular.module('app', []);

// filter to convert html to trusted html.
app.filter('to_trusted', ['$sce', function($sce){
	return function(text) {
		return $sce.trustAsHtml(text);

// Add a controller
app.controller( 'AppCtrl', ['$scope', '$http', function( $scope, $http ) {
	// Load posts from the WordPress API
		cache: true,
		method: 'GET',
		url: '',
		params: {
			'filter[posts_per_page]' : 10
	success( function( data, status, headers, config ) {
		$scope.posts = data;

See Demo or See Codepen Demo [lazy]

See the Pen Angular WP API by Andrew Hudson (@bigandy) on CodePen.


← Home