Join Roy Sivan for an in-depth discussion in this video Creating an AngularJS Controller, part of AngularJS and WordPress: Building a Single-Page Application.
- Angular controllers are easy to create.…The main purpose for a controller…is so Angular knows what functionality to run…based on the route which we will create later.…We'll create a controller,…and call it ListCtrl.…ListCtrl will be the controller that runs…on a blog listing or archive page.…As I said before,…controllers can take on injectable objects,…like scope and the Posts factory,…which we just created.…Now we have a function that will run…when the route matches the controller.…I'm going to go ahead and put something in the console,…so we know that it's running fine.…
I'm going to go ahead and also define out…your variable called page_title,…and just call it a string of Blog Listing.…And finally, I'm going to use our Posts factory…and query the API route that we have defined it to,…and make the response equal to scope.posts.…Now that we have the controller in place,…all we need is some HTML…and a route to view the work.…
In this course, Roy Sivan shows how to build a single-page web app with WordPress, AngularJS, and the WordPress REST API plugin. Roy also reviews creating controllers and routes to get a basic understanding of building a multiview single-page app. Plus, get some tips to transition your single-page app to a native mobile app with AppPresser.
- Setting up WordPress
- Creating the AngularJS components, including the controller and route
- Connecting WordPress and AngularJS
- Connecting views
- Adding and displaying custom data
- Using a plugin to show advanced custom field (ACF) data on the template