Join Roy Sivan for an in-depth discussion in this video Creating an AngularJS Route, part of Building a Single-Page Application with AngularJS and WordPress.
- As I defined before, routes are the way that we connect…URL's to controllers and templates, so that the application…knows what to show and what data it should get,…based on the URL.…We're going to use the UI-Router.…AngularUI is a community run group of projects.…UI-Router being the most popular project.…And it gives us a lot more control over the routing…system that's already built into Angular.…So I'm going to create app.config.…It will have two injectables, stateProvider…and urlRouterProvider.…
First, we're going to create a statement.…And we're going to call it List, which is going to…be our list statement.…The url is going to be home or slash.…The controller is going to be the list control,…which we just created.…And finally the template url, which will be the template…we already created, which is in templates/list.hmtl.…Also, we can do one more thing while we're here, and that's…a back up, just in case the url does not match any of the…states that we defined.…So urlRouterProvider.otherwise/, this says that just in case…
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