You can find it on GitHub here.
How the JSON Works
Since the JSON API is not in WordPress core yet, you’ll need to install it as a plugin: https://wordpress.org/plugins/json-rest-api.
Once it’s installed, you should be able to access the JSON at:
If it looks like an ugly blob of text, I’d highly recommend installing a browser extension to prettify it. I use the JSONView extension for Chrome.
Enqueue the Scripts
This app.js is about as pared down as I could make it. It defines the api path in the root scope, and then fetches the most recent 10 posts in the controller.
If you view the console log in the browser, you should see correct JSON API path outputted, along with the object of data that is returned.
Finally, we need to render these posts on the front end. To do that, we just loop through the returned data in index.php. In this example, I’m just displaying the title and excerpt:
As you can see, it’s pretty simple to get started with Angular with WordPress. If you want to download this little theme to experiment with, you can download it from GitHub.
For the little app I’m building, I’d like to display a quote when someone visits the site. If they want to see another quote, they’ll click a button. I also want the option for unauthenticated visitors to be able to submit a new quote.
So, as I piece this all together, I’ll try to keep posting my progress.