Presented at adaptTo() 2015 in Berlin.
Single-page apps (SPA) have reached critical mass, widely regarded as the most effective pattern for building seamless experiences with web technology. This session will dive into bringing this paradigm to an AEM instance near you - including tips and tricks for leveraging AngularJS to optimize your SPA development, and examples of bringing your content to the app store with Adobe’s PhoneGap.
11. adaptTo()2015 11
“Whenyou decide to not picka public framework, you willend up
witha framework anyway: yourown”
-Ryan Florence,YouCan'tNotHaveaFramework
14. For example:a Single-PageApp
adaptTo()2015 14
Only one “complete” page
often named index.html
Everything else is loaded dynamically, as
required
https://github.com/blefebvre/cordova-sling-blog-sample
17. Your first Angularcomponent
adaptTo()2015 17
Augment theHTML vocabulary as you wish
For example:
<cant-touch-this>
can't touch this!
</cant-touch-this>
bit.ly/cant-touch
18. Your first Angularcomponent
adaptTo()2015 18
app.directive('cantTouchThis', function() {
var link = function(scope, element, attrs) {
element.on('mouseenter', function() {
// move element to random location
});
};
return {
// link this directive to the DOM
link: link
};
});
bit.ly/cant-touch
25. Services Example
adaptTo()2015 25
Each service is a factory function
app.factory(’counterService’, function() {
var count = 1;
return function() {
return count++;
}
}
);
bit.ly/basic-service
29. Solution
adaptTo()2015 29
Serve complete page on author
Produce partials for SPA
Routesgenerated based on hierarchy
go(..) navigates based on wcmmode:
<a ng-click="go('/content/phonegap/app/en/home/subpage')">
Subpage
</a>
30. Solution cont’d
adaptTo()2015 30
Via Sling, each page produces:
“Partial”
subpage.template.html
Data
subpage.angular.json
Supporting assets
sling:resourceType inheritanceFTW!
31. Angular Componentsin AEM
adaptTo()2015 31
Includecq:template node
Prop: frameworkType: angular
Optional: definea controller
Via controller.js.jsp
Optional: includea data file
Via angular.json.jsp
36. adaptTo()2015 36
But… Webvs. Native!
Both built on the same set of technologies
Web capabilities sufficient for most apps
“If abrowserdoesn’tdosomething its notbecauseit can’t;
it’sjustbecausewehaven’tgottenaroundtoimplementing thatpartyet.”
-BrianLeRoux
38. Cordova CLI ata glance
adaptTo()2015 38
Create your app:
cordova create helloAdaptTo
Add a platform:
cd helloAdaptTo
cordova platform add ios
Run your app on a simulator:
cordova emulate ios
48. References
adaptTo()2015 48
YouCan'tNotHave a Framework- RyanFlorence
Thumbsupimage
Thumbsdownimage
U can’ttouchthis– MC Hammer
PedestrianDetour
N64controllerGray–Evan-Amos
Hardhatandgloves –Compliance and Safety
Devices image
Unixstickers‘all thethings’
Editor's Notes
Something for the sling users as well
Adobe for 3.5 yrs
CQ/AEM mobile team
Why AEM and Angular are a good fit
For example
TODO: Add some stats to this page on how quickly sites are abandoned
Whether we’re talking apps or web, connectivity is not a guarantee
Lets talk about some of the benefits
TODO: add iPhone borders
..following best practices…
…don’t reinvent the wheel…
JS; does not follow progressive enhancement techniques
Dojo
Ember
Backbone
Angular
Monolithic vs micro
“there’s a lot of fashion in JS”- don’t just pick a framework cause all the cool kids are doing it
Simply handle the business logic for a view
For everything else, there’s services
Backed by Google; not going anywhere
Community:
Ionic Framework
Snap.js
btford/angular-phonegap-ready
Docs + Stack Overflow
Backed by Google; not going anywhere
PRETTY COOL
.. Of course there are a few lines of angular behind the scenes..
Singletons: “Each component dependent on a service gets a reference to the single instance generated by the service factory”
TIME: 17 min
Singletons: “Each component dependent on a service gets a reference to the single instance generated by the service factory”
Simply handle the business logic for a view
Singletons: “Each component dependent on a service gets a reference to the single instance generated by the service factory”
Singletons: “Each component dependent on a service gets a reference to the single instance generated by the service factory”
Singletons: “Each component dependent on a service gets a reference to the single instance generated by the service factory”
Singletons: “Each component dependent on a service gets a reference to the single instance generated by the service factory”
2016?
A cross-platform app framework
Initially PhoneGap, created by Nitobi
Donated to ASF in 2011 as Cordova
of which PhoneGap is a distribution
- like (C, C++)
TODO: include AEM apps image
mobile services details
would be wrong to tout the virtues of the open web, and keep all my source code closed: everything is available on github
I’ll be around for the hackathon this aft
Thank you very much for your attention.