18
GitHub: https://github.com/WPKitIO/WPKit Slides: https://goo.gl/MgNg1O Intro to Developing Websites with AngularJS and WordPress

Intro to Developing Web Sites with WordPress and AngularJS

Embed Size (px)

Citation preview

Page 1: Intro to Developing Web Sites with WordPress and AngularJS

GitHub: https://github.com/WPKitIO/WPKitSlides: https://goo.gl/MgNg1O

Intro toDeveloping Websites with

AngularJS and WordPress

Page 3: Intro to Developing Web Sites with WordPress and AngularJS

AgendaWhat we do. And Why.What is AngularJS?Why AngularJS?Why WordPress?Quick How ToWordPress/AngularJS DemoHow We Use AngularJS and WordPress in ProductionQuestions?

@BenENewton @Joedajigalo #wcmia

Page 4: Intro to Developing Web Sites with WordPress and AngularJS

What We Do. And Why.We are using one WordPress back end as an API endpoint for multiple front end “clients”.

One WordPress installation can serve data for:Multiple Websites,Apps,Landing Pages,Adsand more.

@BenENewton @Joedajigalo #wcmia

Page 5: Intro to Developing Web Sites with WordPress and AngularJS

What is AngularJS?From The AngularJS Documentation

AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly and succinctly. Angular's data binding and dependency injection eliminate much of the code you would otherwise have to write.

@BenENewton @Joedajigalo #wcmia

Page 6: Intro to Developing Web Sites with WordPress and AngularJS

Why AngularJS?Reusable ServicesEasy Injection of data from any back end endpoint

Simple HTML Templating<div>Easy as {{this}}</div>

SpeedServe static HTML Pages and still have dynamic content

Separate production teams.Front End Devs/Back End Devs

@BenENewton @Joedajigalo #wcmia

Page 7: Intro to Developing Web Sites with WordPress and AngularJS

Why WordPress?

Easy to ModifyWell supportedHuge communityClient friendly

@BenENewton @Joedajigalo #wcmia

Page 8: Intro to Developing Web Sites with WordPress and AngularJS

Demo -

https://github.com/WPKitIO/WPKit/tree/Car-Example

*Requires Mamp and Gulp

@BenENewton @Joedajigalo #wcmia

Page 9: Intro to Developing Web Sites with WordPress and AngularJS

AngularJS Simple Repeater

FactoryControllerTemplate

@BenENewton @Joedajigalo #wcmia

Page 10: Intro to Developing Web Sites with WordPress and AngularJS

AngularJS Factoryangular.module('wpKit').factory('carFactory', function ($resource, CONFIG) { return $resource('http://' + CONFIG.apiBaseUrl + '/cars/:car', { callback: 'JSON_CALLBACK', car: '@car' }, { getData: {method: 'JSONP', params: { car: ''} } });});

@BenENewton @Joedajigalo #wcmia

Page 11: Intro to Developing Web Sites with WordPress and AngularJS

AngularJS Controllerangular.module('wpKit').controller('carCtrl', function ($scope, carFactory, $routeParams) {

var carName = $routeParams.car;

carFactory.getData( { car: carName }, function(data) { $scope.pageInformation = data.page_information; $scope.car = data.car; });});

@BenENewton @Joedajigalo #wcmia

Page 12: Intro to Developing Web Sites with WordPress and AngularJS

AngularJS Repeater<img ng-src="{{car.image}}" />

<h1>{{car.name}}</h1>

<p ng-bind-html="car.description" ></p>

<ul> <li ng-repeat="model in car.models" > <img ng-src="{{model.image}}" /> <span ng-bind-html="model.name"></span> <span>${{model.msrp}}</span> </li></ul>

@BenENewton @Joedajigalo #wcmia

Page 13: Intro to Developing Web Sites with WordPress and AngularJS

{ "page_information": { "id": 9, "slug": "cayman", "template": "single-cars.php" }, "car": { "manufacturer": { "name": "Porsche", "slug": "porsche" }, "name": "Cayman", "description": "The Porsche Cayman is a rear mid-engined, rear wheel drive 2-seat sports car produced by Porsche AG of Germany.", "image": "http:\/\/localhost\/wpkit\/wp-content\/uploads\/2015\/05\/cayman-featured-image.jpg" , "models": [{ "name": "Cayman GT4" , "msrp": "84,600.00" , "image": "http:\/\/localhost\/wpkit\/wp-content\/uploads\/2015\/05\/cayman-gt4.png" }, { "name": "Cayman", "msrp": "52,600.00" , "image": "http:\/\/localhost\/wpkit\/wp-content\/uploads\/2015\/05\/cayman.png" }, { "name": "Cayman S" , "msrp": "64,100.00" , "image": "http:\/\/localhost\/wpkit\/wp-content\/uploads\/2015\/05\/cayman-s.png" }, { "name": "Cayman GTS" , "msrp": "75,200.00" , "image": "http:\/\/localhost\/wpkit\/wp-content\/uploads\/2015\/05\/cayman-gts.png" }] }}

@BenENewton @Joedajigalo #wcmia

Page 14: Intro to Developing Web Sites with WordPress and AngularJS

ProsMultiple Platforms using same dataSeparate dev teamsCut dev TimeNo need for WordPress staging serverBuild new sites without touching back endSuper Fast DeploymentEasily ScalesInexpensive Hosting

@BenENewton @Joedajigalo #wcmia

Page 15: Intro to Developing Web Sites with WordPress and AngularJS

How We Use AngularJS and WordPress in Production@BenENewton @Joedajigalo #wcmia

Norwegian Escape Site - escape.ncl.com

Page 16: Intro to Developing Web Sites with WordPress and AngularJS

@BenENewton @Joedajigalo #wcmia

On

Sites for 8 CountriesSpecial Use Site that may serve up to 4000+ micro sites.Future sitesFuture Apps

All from the same WordPress Install

How We Use AngularJS and WordPress in Production

Page 17: Intro to Developing Web Sites with WordPress and AngularJS

Angular ResourcesAngularJS Developer Guide - https://docs.angularjs.org/guide/introductionAngularJS Docs - Getting Started - https://docs.angularjs.org/misc/startedEgghead.io - https://egghead.io/technologies/angularjsAdventures in Angular Podcast - http://devchat.tv/adventures-in-angular

@BenENewton @Joedajigalo #wcmia

Page 18: Intro to Developing Web Sites with WordPress and AngularJS

Questions?

GitHub Repo:https://github.com/WPKitIO/WPKit/tree/Car-Example

Twitter@BenENewton @joedajigalo

#wcmia