{"id":1099,"date":"2016-08-20T14:27:27","date_gmt":"2016-08-20T05:27:27","guid":{"rendered":"https:\/\/n8finch2024.local\/?p=1099"},"modified":"2019-06-30T07:02:20","modified_gmt":"2019-06-29T22:02:20","slug":"adding-angular-markup-genesis-child-theme","status":"publish","type":"post","link":"https:\/\/n8finch2024.local\/adding-angular-markup-genesis-child-theme\/","title":{"rendered":"Adding Angular Markup to a Genesis Child Theme (Part 1)"},"content":{"rendered":"

This is the second\u00a0post in a three part series on using Genesis and Angular. Part 2 can be read here<\/strong><\/a>, and Part 3 can be read here<\/strong><\/a>.\u00a0<\/em><\/p>\n

This month is Angular August<\/a>“<\/strong>, and so I’ve been focusing on learning Angular (1, not 2\u00a0yet… but soon!).\u00a0I’ve set myself several tasks\u00a0learning angular, one of which is developing a starter Genesis child theme using Angular and Gulp (since I’ve been wanting to check out and use Gulp more too… I still love you, Grunt). Here\u00a0is what I’m trying to do with this project:<\/p>\n

Primary objective:\u00a0<\/strong>Create a view area that will display all the contents of posts and pages without a page reload using\u00a0Genesis and Angular.<\/p>\n

Do this by:<\/p>\n

    \n
  1. Adding markup to my Genesis child theme<\/li>\n
  2. Fetching data with the WP REST API and Angular<\/li>\n
  3. Routing the data with Angular on posts and pages<\/li>\n<\/ol>\n

    If you’ve used Angular, you know you need to specify ng-app<\/code>\u00a0and ng-view<\/code>\u00a0in your html markup so that your Angular app will run.\u00a0This is easy to do with a starter theme like _’s, but if you’re building on top of a framework like Genesis, you need to use the available hooks and filters<\/code>\u00a0to manage your markup.<\/p>\n

    I’m a part of the community at WP Developer Club and KnowtheCode.io<\/strong><\/a>, and Tonya does a great job walking through the markup.php<\/code>\u00a0file and structure in Genesis. Check it out and join up if you’re thirsty for knowledge!<\/p>\n

    So, here’s how I finally landed on the markup I needed to be able to add\u00a0the basic Angular directives to my Genesis Markup…<\/p>\n

    (Note:\u00a0<\/strong>Unless otherwise noted, all PHP goes in the function.php<\/code>\u00a0file and all JavaScript has been enqueued from a main.js<\/code> file)<\/p>\n

    <\/p>\n

    Adding Directives and\u00a0Properties with Values to Attributes<\/h2>\n

    With Angular, there are several directives you need to place in your HTML for an app to work, or in this case, for a Genesis child theme to assume an app-like state. This include:<\/p>\n