Académique Documents
Professionnel Documents
Culture Documents
My Background
AngularJS pros
Misko
Testable frontend framework
Old: jsUnit & Selenium
New: Jasmine & Karma (or jsTestDriver)
AngularJS cons
Wants to own the DOM
Directive required to play well with others
PhoneGap background
Created in 2009 at iPhoneDevCamp event
Enabled access to native device features
geo-location
accelerometers
camera
push notifications
PhoneGap
embeds HTML5 code inside a WebView
able to be extended with native plug-ins
makes native accessible from JavaScript
web based mobile app you can put in
iOS App Store, or Google Play Store
Build & deploy tools allow you to write 1.5x and
run everywhere
Can be used with almost any web framework
PhoneGap visualized
PhoneGap in 15 secs
Of course you have node installed!
http://madebyhoundstooth.com/blog/install-node-with-homebrew-on-os-x
PhoneGap gotchas
web apps can be slower than native
especially on older phones
ngTouch module
http://docs.angularjs.org/api/ngTouch
The ngTouch module provides touch events and
other helpers (but it is not ready yet!)
Will have ng-click that doesnt wait 300 ms
Has ng-swipe-left & ng-swipe-right directives
And, $swipe service that abstracts drag & swipe
However, you should:
Check out https://github.com/ftlabs/fastclick to
save those 300ms in the meantime
new FastClick(document.body);
angular-mobile-nav
https://github.com/ajoslin/angular-mobile-nav
simple (lightweight) mobile navigation service
Transitions between partials
<mobile-view> instead of <ng-view>
angular-gestures
https://github.com/wzr1337/angular-gestures
Based on hammer.js
events for Tap, DoubleTap, Swipe, Drag, Pinch, Rotate
<div style="transform:rotate({{rotation}}deg) scale
({{scaleFactor }});"
hm-pinch="pinch($event)" hm-rotate="rotate($event)" ></div>
$scope.rotate = function(event) {
$scope.rotation = event.gesture.rotation % 360;
event.gesture.preventDefault();
}
$scope.pinch = function(event) {
$scope.scaleFactor = event.gesture.scale;
event.gesture.preventDefault();
}
examples
angular-jqm
github.com/angular-widgets/angular-jqm
for more full scale app solution (still in alpha)
Native AngularJS directives for jQuery
Mobile function (but no jQuery dependency)
Replaces jquery-mobile-angular-adapter
which was dependent on jQuery
Includes angular-scrolly for iOS looking
scrolling done with element transforms
AngularJS Native
Angular wrappers around Cordovas javascript
libraries that bridge native functionality. All
available from Bower
https://github.com/btford/angular-phonegap-accelerometer
https://github.com/btford/angular-phonegap-notification
vibration, haptic
https://github.com/btford/angular-phonegap-geolocation
angular-carousel
https://github.com/revolunet/angular-carousel
An AngularJS carousel implementation
optimised for mobile devices
<ul rn-carousel class="image">
<li ng-repeat="image in images"
style="background-image:url({{ image
}});">
<div class="layer">image #{{ $index }}</div>
</li>
</ul>
angular-snap
https://github.com/jtrussell/angular-snap.js
An AngularJS carousel implementation
optimised for mobile devices
<snap-drawer>
This is the menu contents
</snap-drawer>
<snap-content>
This is your page content
<button snap-toggle="left">Toggle Snap</button>
</snap-content>
Optimizations
Minimize DOM
Minimize http calls to prevent latency
Preload ng-templates
https://github.com/karlgoldstein/grunt-html2js OR
https://npmjs.org/package/grunt-angular-templates
Resources
http://briantford.com/blog/angular-phonegap.html
http://devgirl.org/2013/06/10/quick-start-guide-phonegap-and-angularjs
http://blog.revolunet.com/angular-for-mobile
YouTube:
Building Mobile Apps with AngularJS and PhoneGap - Brian Ford
Creating PhoneGap Apps with AngularJS & Topcoat