SlideShare a Scribd company logo
Cordova development 
with AngularJS 
… and UI component libraries
Me 
● Andreas Argelius 
● From Sweden 
● Living in Japan 
● Loves food and beer
Me 
● Works for Asial Corporation 
● Developer on Onsen UI 
… so I might be slightly biased towards AngularJS and Onsen UI
Cordova 
Hybrid apps using 
web technologies. 
Java 
Objective-C
SPA (Single Page Application) 
The whole app in one HTML file 
● No page reload 
● Manipulate DOM with JavaScript 
● Load content dynamically 
More fluid and “native” feel.
SPA Frameworks
AngularJS 
● Client-side framework 
● Separates DOM manipulation from logic 
● Two-way data binding
AngularJS - features 
Services 
Objects that can be inserted in various places through dependency injection. 
Directives 
Define reusable custom HTML tags, attributes or classes. 
Controllers 
Control application state.
Services 
Substitutable objects that can be used 
throughout your application. 
What can we use services for? 
● Data storage, e.g. database models 
● Calling APIs (both local and external)
Services - example 
var module = angular.module('myServices', []); 
module.factory('$myService', function() { 
return { 
doSomething: function() { 
// Do stuff! 
} 
}; 
});
Dependency injection 
Inject dependencies into controllers, directives 
and services 
var app = angular.module('myApp', ['myServices']); 
app.controller('MyController', function($myService) { 
$myService.doSomething(); 
});
Services - substitutable 
● Services should be substitutable by a service 
with same API. 
● Use promises even if without async calls in 
service. 
If you switch from localStorage to some remote storage the service will be 
substitutable if you used promises for the original version, even if localStorage 
isn’t asynchronous.
Reasons for using services 
● Promotes modular design 
● Data abstraction 
● Consistency 
Don’t repeat yourself!
Services are singleton instances 
Only initialized once (lazily)
Services in Cordova 
Possible usage in Cordova development: 
Angularize native APIs 
Wrap API calls in AngularJS services
Example - GeoLocation 
angular.module('app.services', []). 
factory('$geolocation', function($q) { 
return { 
get: function() { 
var deferred = $q.defer(); 
... 
return deferred.promise; 
} 
}; 
});
Example - GeoLocation 
angular.module('app', ['app.services']). 
controller('PositionController', function($scope, $geolocation) { 
$geolocation.get().then(function(position) { 
$scope.currentPosition = position; 
}, 
function(error) { 
// Handle error. 
}) 
}); 
https://gist.github.com/argelius/2ecf0b7c08f31a11eaff
ngCordova 
● Camera, GeoLocation, Accelerometer, etc. 
● AngularJS services 
● Uses $q promises 
github.com/driftyco/ng-cordova
Example - GeoLocation 
angular.module('app', ['ngCordova']). 
controller('LocationController', function($cordovaGeolocation) { 
$cordovaGeolocation. 
getCurrentPosition(). 
then(function(position) { 
// Do stuff. 
}, ...); 
});
ngTouch 
Touch events and helpers. 
● Attribues: ng-click, ng-swipe-left, ng-swipe- 
right 
● $swipe service, to capture touch events.
ngTouch 
Part of standard library 
<script src=”angular-touch.js”></script> 
<script> 
angular.module('app', ['ngTouch']); 
</script>
ngClick 
<button ng-click=”doSomething()”> 
Click me! 
</button> 
Replaces regular ng-click. Mobile browsers 
introduce a 300ms delay. ngTouch removes delay.
Swipe handlers 
<div 
ng-controller=”CarouselCtrl” 
ng-swipe-left=”next()” 
ng-swipe-right=”prev()”> 
... 
</div>
$swipe service 
Only one method: $swipe.bind() 
$swipe.bind({ 
start: function(e) { 
// listens for 'mousedown' or 'touchstart' 
console.log('You tapped (' + e.x + ',' + e.y + ')'); 
} 
// also 'move', 'end' and 'cancel'. 
}
Directives 
● Attach a behavior or change a DOM element 
● Create custom tags, attributes or classes 
● Allows for cleaner markup 
Using: 
module.directive( 'myDirective' , function($dep1, $dep2) { 
... 
});
Directives - example 
angular.module('app', []) 
.directive('myOwnToolbar', function() { 
return { 
restrict: 'E' 
// Lots of options that control 
// the behavior of the directive. 
}; 
});
Directives - example 
Use it in your markup: 
<my-own-toolbar> 
My very own application! 
</my-own-toolbar>
Memory leaks 
Your directives may leak, 
be careful! 
Be nice to the garbage collector.
Memory leaks 
If an object owns a reference to the DOM element, you must 
remove it when the directive is removed from the DOM. 
scope.$on('$destroy', function() { 
this._element = null; 
}.bind(this)); 
Also remove event listeners!
Memory leaks 
● Mobile devices have less memory than desktop 
computers 
● Hybrid apps may be open for a very long time 
● Even a small memory leak may be disastrous!
Chrome Timeline 
Detect memory leaks. Compare state before and after leaking 
action. 
Number of nodes should be same when returning to original state.
Directives in Cordova 
Nice way to use directives in Cordova: 
● Emulate native UI components to make users 
feel at home. 
● Utilize native APIs directly from the markup.
Native app components 
● Page navigation 
● Tab bar 
● Toolbar 
● List view 
Cordova apps shouldn’t feel like 
web applications!
UI components 
Lots of other frameworks also available: 
http://propertycross.com/
Built on top of Angular 
● Ionic and Onsen use AngularJS to create 
custom tags. 
● Natural to write the app using AngularJS since 
it’s already loaded.
Onsen UI ng-model 
Integrates with AngularJS 
<ons-switch ng-model=”switchState”></ons-switch> 
<p>State is: {{ switchState }}</p>
Onsen UI ng-model 
Works like a checkbox:
Components example 
● Sample Sushifinder app 
● Gets position with $geolocation service we 
created before 
● Asks foursquare API for nearby sushi 
restaurants 
https://github.com/argelius/ionic-sushifinder
Sushifinder - Ionic
Ionic 
<ion-navbar> 
... 
</ion-navbar>
Ionic 
<ion-list> 
<ion-item> 
... 
</ion-item> 
... 
</ion-list>
Ionic 
<ion-tabs> 
<ion-tab 
icon=”icon ion-search” ></ion-tab> 
... 
</ion-tabs>
Onsen UI 
<ons-toolbar> 
... 
</ons-toolbar>
Onsen UI 
<ons-list> 
<ons-list-item modifier= ”chevron”> 
... 
</ons-list-item> 
</ons-list>
Onsen UI 
<ons-tabbar> 
<ons-tabbar-item page= ”find.html” > 
</ons-tabbar-item> 
... 
</ons-tabbar>
Thank you 
for listening!

More Related Content

What's hot

AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project 
Elad Hirsch
 
Why angular js Framework
Why angular js Framework Why angular js Framework
Why angular js Framework
Sakthi Bro
 
Workshop 16: EmberJS Parte I
Workshop 16: EmberJS Parte IWorkshop 16: EmberJS Parte I
Workshop 16: EmberJS Parte I
Visual Engineering
 
Coffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JSCoffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JS
Deepu S Nath
 
The Art of AngularJS - DeRailed 2014
The Art of AngularJS - DeRailed 2014The Art of AngularJS - DeRailed 2014
The Art of AngularJS - DeRailed 2014
Matt Raible
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
Betclic Everest Group Tech Team
 
Single Page Applications in SharePoint with Angular
Single Page Applications in SharePoint with AngularSingle Page Applications in SharePoint with Angular
Single Page Applications in SharePoint with Angular
Sparkhound Inc.
 
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
Dynamic Application Development by NodeJS ,AngularJS with OrientDBDynamic Application Development by NodeJS ,AngularJS with OrientDB
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
Apaichon Punopas
 
Angular js
Angular jsAngular js
Angular js
Dinusha Nandika
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
Sagar Acharya
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architecture
Michael He
 
AngularJS best-practices
AngularJS best-practicesAngularJS best-practices
AngularJS best-practices
Henry Tao
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
Jussi Pohjolainen
 
Workshop 9: BackboneJS y patrones MVC
Workshop 9: BackboneJS y patrones MVCWorkshop 9: BackboneJS y patrones MVC
Workshop 9: BackboneJS y patrones MVC
Visual Engineering
 
Angularjs - lazy loading techniques
Angularjs - lazy loading techniques Angularjs - lazy loading techniques
Angularjs - lazy loading techniques
Nir Kaufman
 
AngularJS Introduction
AngularJS IntroductionAngularJS Introduction
AngularJS Introduction
Carlos Morales
 
Introduction to AJAX In WordPress
Introduction to AJAX In WordPressIntroduction to AJAX In WordPress
Introduction to AJAX In WordPress
Caldera Labs
 
Gettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJSGettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJS
Armin Vieweg
 

What's hot (20)

AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project 
 
Why angular js Framework
Why angular js Framework Why angular js Framework
Why angular js Framework
 
Workshop 16: EmberJS Parte I
Workshop 16: EmberJS Parte IWorkshop 16: EmberJS Parte I
Workshop 16: EmberJS Parte I
 
Coffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JSCoffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JS
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
The Art of AngularJS - DeRailed 2014
The Art of AngularJS - DeRailed 2014The Art of AngularJS - DeRailed 2014
The Art of AngularJS - DeRailed 2014
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
Single Page Applications in SharePoint with Angular
Single Page Applications in SharePoint with AngularSingle Page Applications in SharePoint with Angular
Single Page Applications in SharePoint with Angular
 
Angular - Beginner
Angular - BeginnerAngular - Beginner
Angular - Beginner
 
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
Dynamic Application Development by NodeJS ,AngularJS with OrientDBDynamic Application Development by NodeJS ,AngularJS with OrientDB
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
 
Angular js
Angular jsAngular js
Angular js
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architecture
 
AngularJS best-practices
AngularJS best-practicesAngularJS best-practices
AngularJS best-practices
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Workshop 9: BackboneJS y patrones MVC
Workshop 9: BackboneJS y patrones MVCWorkshop 9: BackboneJS y patrones MVC
Workshop 9: BackboneJS y patrones MVC
 
Angularjs - lazy loading techniques
Angularjs - lazy loading techniques Angularjs - lazy loading techniques
Angularjs - lazy loading techniques
 
AngularJS Introduction
AngularJS IntroductionAngularJS Introduction
AngularJS Introduction
 
Introduction to AJAX In WordPress
Introduction to AJAX In WordPressIntroduction to AJAX In WordPress
Introduction to AJAX In WordPress
 
Gettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJSGettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJS
 

Viewers also liked

The 10 Commandments of Electromagnetic Compatibility
The 10 Commandments of Electromagnetic CompatibilityThe 10 Commandments of Electromagnetic Compatibility
The 10 Commandments of Electromagnetic Compatibility
Jaymie Murray
 
Community Manager Appreciation Day 2013
Community Manager Appreciation Day 2013Community Manager Appreciation Day 2013
Community Manager Appreciation Day 2013
Michael Norton
 
Things I like, I love and I hate.
Things I like, I love and I hate.Things I like, I love and I hate.
Things I like, I love and I hate.nachisoukaina
 
7 Principles for Engaging Users with Visualization
7 Principles for Engaging Users with Visualization7 Principles for Engaging Users with Visualization
7 Principles for Engaging Users with Visualization
Benjamin Wiederkehr
 
Augmented Reality Press Conference - Zlatestranky.cz
Augmented Reality Press Conference - Zlatestranky.czAugmented Reality Press Conference - Zlatestranky.cz
Augmented Reality Press Conference - Zlatestranky.czPavel Kotyza
 
Library%20in%20 Your%20 Pocket Slideshare[1]
Library%20in%20 Your%20 Pocket Slideshare[1]Library%20in%20 Your%20 Pocket Slideshare[1]
Library%20in%20 Your%20 Pocket Slideshare[1]
guestf4e976
 
Week 14 learning objectives
Week 14 learning objectivesWeek 14 learning objectives
Week 14 learning objectivesYap Hooi
 
Talent webinar slides 6 25 2015 final
Talent webinar slides 6 25 2015 finalTalent webinar slides 6 25 2015 final
Talent webinar slides 6 25 2015 final
Lora Cecere
 
Talent pipeline activation webinar
Talent pipeline activation webinarTalent pipeline activation webinar
Talent pipeline activation webinar
LinkedIn
 
Presentación sobre Derechos Humanos
Presentación sobre Derechos HumanosPresentación sobre Derechos Humanos
Presentación sobre Derechos Humanos
Joaquin Sanchez
 
19 plan & section of penstock
19 plan & section of  penstock19 plan & section of  penstock
19 plan & section of penstock
Nikhil Jaipurkar
 
Chindogu
ChindoguChindogu
Chindogu
Susan Lieberman
 
風險測試
風險測試風險測試
風險測試excel2003
 
Galicia - Comenius Project
Galicia - Comenius ProjectGalicia - Comenius Project
Galicia - Comenius Project
laborcomenius
 
5° básico b semana 23 al 27 mayo
5° básico b  semana 23  al 27 mayo5° básico b  semana 23  al 27 mayo
5° básico b semana 23 al 27 mayo
Colegio Camilo Henríquez
 
AFC Café: Nick geukens
AFC Café: Nick geukensAFC Café: Nick geukens
AFC Café: Nick geukensAFC Leuven
 
Overview of Using Wordpress for Web Site Design
Overview of Using Wordpress for Web Site DesignOverview of Using Wordpress for Web Site Design
Overview of Using Wordpress for Web Site Design
Amy Goodloe
 

Viewers also liked (20)

The 10 Commandments of Electromagnetic Compatibility
The 10 Commandments of Electromagnetic CompatibilityThe 10 Commandments of Electromagnetic Compatibility
The 10 Commandments of Electromagnetic Compatibility
 
Community Manager Appreciation Day 2013
Community Manager Appreciation Day 2013Community Manager Appreciation Day 2013
Community Manager Appreciation Day 2013
 
Things I like, I love and I hate.
Things I like, I love and I hate.Things I like, I love and I hate.
Things I like, I love and I hate.
 
7 Principles for Engaging Users with Visualization
7 Principles for Engaging Users with Visualization7 Principles for Engaging Users with Visualization
7 Principles for Engaging Users with Visualization
 
Augmented Reality Press Conference - Zlatestranky.cz
Augmented Reality Press Conference - Zlatestranky.czAugmented Reality Press Conference - Zlatestranky.cz
Augmented Reality Press Conference - Zlatestranky.cz
 
Library%20in%20 Your%20 Pocket Slideshare[1]
Library%20in%20 Your%20 Pocket Slideshare[1]Library%20in%20 Your%20 Pocket Slideshare[1]
Library%20in%20 Your%20 Pocket Slideshare[1]
 
Week 14 learning objectives
Week 14 learning objectivesWeek 14 learning objectives
Week 14 learning objectives
 
Talent webinar slides 6 25 2015 final
Talent webinar slides 6 25 2015 finalTalent webinar slides 6 25 2015 final
Talent webinar slides 6 25 2015 final
 
Talent pipeline activation webinar
Talent pipeline activation webinarTalent pipeline activation webinar
Talent pipeline activation webinar
 
ขยายเวลาเปิดรับข้อเสนอโครงการงบสกอ. ประจำปีงบประมาณ 2557
ขยายเวลาเปิดรับข้อเสนอโครงการงบสกอ. ประจำปีงบประมาณ 2557ขยายเวลาเปิดรับข้อเสนอโครงการงบสกอ. ประจำปีงบประมาณ 2557
ขยายเวลาเปิดรับข้อเสนอโครงการงบสกอ. ประจำปีงบประมาณ 2557
 
Presentación sobre Derechos Humanos
Presentación sobre Derechos HumanosPresentación sobre Derechos Humanos
Presentación sobre Derechos Humanos
 
19 plan & section of penstock
19 plan & section of  penstock19 plan & section of  penstock
19 plan & section of penstock
 
Chindogu
ChindoguChindogu
Chindogu
 
風險測試
風險測試風險測試
風險測試
 
CV Ahmed madeeh
CV Ahmed madeeh CV Ahmed madeeh
CV Ahmed madeeh
 
Galicia - Comenius Project
Galicia - Comenius ProjectGalicia - Comenius Project
Galicia - Comenius Project
 
5° básico b semana 23 al 27 mayo
5° básico b  semana 23  al 27 mayo5° básico b  semana 23  al 27 mayo
5° básico b semana 23 al 27 mayo
 
AFC Café: Nick geukens
AFC Café: Nick geukensAFC Café: Nick geukens
AFC Café: Nick geukens
 
Overview of Using Wordpress for Web Site Design
Overview of Using Wordpress for Web Site DesignOverview of Using Wordpress for Web Site Design
Overview of Using Wordpress for Web Site Design
 
Radin Brand Experience_2
Radin Brand Experience_2Radin Brand Experience_2
Radin Brand Experience_2
 

Similar to SF Cordova Meetup

Intro to AngularJs
Intro to AngularJsIntro to AngularJs
Intro to AngularJs
SolTech, Inc.
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte II
Visual Engineering
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
Gaurav Agrawal
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
Tamer Solieman
 
AngularJs Crash Course
AngularJs Crash CourseAngularJs Crash Course
AngularJs Crash Course
Keith Bloomfield
 
AngularJS 101
AngularJS 101AngularJS 101
AngularJS 101
Houssem Yahiaoui
 
Mean stack Magics
Mean stack MagicsMean stack Magics
Mean stack Magics
Aishura Aishu
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development Guide
Nitin Giri
 
Mini-Training: AngularJS
Mini-Training: AngularJSMini-Training: AngularJS
Mini-Training: AngularJS
Betclic Everest Group Tech Team
 
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle StudiosAngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
Learnimtactics
 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practice
Eugene Fidelin
 
Angular js slides
Angular js slidesAngular js slides
Angular js slides
Amr Abd El Latief
 
Angular js 1.3 presentation for fed nov 2014
Angular js 1.3 presentation for fed   nov 2014Angular js 1.3 presentation for fed   nov 2014
Angular js 1.3 presentation for fed nov 2014
Sarah Hudson
 
The Basics Angular JS
The Basics Angular JS The Basics Angular JS
The Basics Angular JS
OrisysIndia
 
Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01
Arunangsu Sahu
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with Karma
ExoLeaders.com
 
Angular js
Angular jsAngular js
Angular js
Knoldus Inc.
 

Similar to SF Cordova Meetup (20)

Intro to AngularJs
Intro to AngularJsIntro to AngularJs
Intro to AngularJs
 
Angular js
Angular jsAngular js
Angular js
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte II
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
 
AngularJs Crash Course
AngularJs Crash CourseAngularJs Crash Course
AngularJs Crash Course
 
AngularJS 101
AngularJS 101AngularJS 101
AngularJS 101
 
Mean stack Magics
Mean stack MagicsMean stack Magics
Mean stack Magics
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development Guide
 
Mini-Training: AngularJS
Mini-Training: AngularJSMini-Training: AngularJS
Mini-Training: AngularJS
 
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle StudiosAngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
 
Training On Angular Js
Training On Angular JsTraining On Angular Js
Training On Angular Js
 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practice
 
Angular js slides
Angular js slidesAngular js slides
Angular js slides
 
Angular js 1.3 presentation for fed nov 2014
Angular js 1.3 presentation for fed   nov 2014Angular js 1.3 presentation for fed   nov 2014
Angular js 1.3 presentation for fed nov 2014
 
The Basics Angular JS
The Basics Angular JS The Basics Angular JS
The Basics Angular JS
 
Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01
 
AngularJs
AngularJsAngularJs
AngularJs
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with Karma
 
Angular js
Angular jsAngular js
Angular js
 

Recently uploaded

Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 

Recently uploaded (20)

Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 

SF Cordova Meetup

  • 1. Cordova development with AngularJS … and UI component libraries
  • 2. Me ● Andreas Argelius ● From Sweden ● Living in Japan ● Loves food and beer
  • 3. Me ● Works for Asial Corporation ● Developer on Onsen UI … so I might be slightly biased towards AngularJS and Onsen UI
  • 4. Cordova Hybrid apps using web technologies. Java Objective-C
  • 5. SPA (Single Page Application) The whole app in one HTML file ● No page reload ● Manipulate DOM with JavaScript ● Load content dynamically More fluid and “native” feel.
  • 7. AngularJS ● Client-side framework ● Separates DOM manipulation from logic ● Two-way data binding
  • 8. AngularJS - features Services Objects that can be inserted in various places through dependency injection. Directives Define reusable custom HTML tags, attributes or classes. Controllers Control application state.
  • 9. Services Substitutable objects that can be used throughout your application. What can we use services for? ● Data storage, e.g. database models ● Calling APIs (both local and external)
  • 10. Services - example var module = angular.module('myServices', []); module.factory('$myService', function() { return { doSomething: function() { // Do stuff! } }; });
  • 11. Dependency injection Inject dependencies into controllers, directives and services var app = angular.module('myApp', ['myServices']); app.controller('MyController', function($myService) { $myService.doSomething(); });
  • 12. Services - substitutable ● Services should be substitutable by a service with same API. ● Use promises even if without async calls in service. If you switch from localStorage to some remote storage the service will be substitutable if you used promises for the original version, even if localStorage isn’t asynchronous.
  • 13. Reasons for using services ● Promotes modular design ● Data abstraction ● Consistency Don’t repeat yourself!
  • 14. Services are singleton instances Only initialized once (lazily)
  • 15. Services in Cordova Possible usage in Cordova development: Angularize native APIs Wrap API calls in AngularJS services
  • 16. Example - GeoLocation angular.module('app.services', []). factory('$geolocation', function($q) { return { get: function() { var deferred = $q.defer(); ... return deferred.promise; } }; });
  • 17. Example - GeoLocation angular.module('app', ['app.services']). controller('PositionController', function($scope, $geolocation) { $geolocation.get().then(function(position) { $scope.currentPosition = position; }, function(error) { // Handle error. }) }); https://gist.github.com/argelius/2ecf0b7c08f31a11eaff
  • 18. ngCordova ● Camera, GeoLocation, Accelerometer, etc. ● AngularJS services ● Uses $q promises github.com/driftyco/ng-cordova
  • 19. Example - GeoLocation angular.module('app', ['ngCordova']). controller('LocationController', function($cordovaGeolocation) { $cordovaGeolocation. getCurrentPosition(). then(function(position) { // Do stuff. }, ...); });
  • 20. ngTouch Touch events and helpers. ● Attribues: ng-click, ng-swipe-left, ng-swipe- right ● $swipe service, to capture touch events.
  • 21. ngTouch Part of standard library <script src=”angular-touch.js”></script> <script> angular.module('app', ['ngTouch']); </script>
  • 22. ngClick <button ng-click=”doSomething()”> Click me! </button> Replaces regular ng-click. Mobile browsers introduce a 300ms delay. ngTouch removes delay.
  • 23. Swipe handlers <div ng-controller=”CarouselCtrl” ng-swipe-left=”next()” ng-swipe-right=”prev()”> ... </div>
  • 24. $swipe service Only one method: $swipe.bind() $swipe.bind({ start: function(e) { // listens for 'mousedown' or 'touchstart' console.log('You tapped (' + e.x + ',' + e.y + ')'); } // also 'move', 'end' and 'cancel'. }
  • 25. Directives ● Attach a behavior or change a DOM element ● Create custom tags, attributes or classes ● Allows for cleaner markup Using: module.directive( 'myDirective' , function($dep1, $dep2) { ... });
  • 26. Directives - example angular.module('app', []) .directive('myOwnToolbar', function() { return { restrict: 'E' // Lots of options that control // the behavior of the directive. }; });
  • 27. Directives - example Use it in your markup: <my-own-toolbar> My very own application! </my-own-toolbar>
  • 28. Memory leaks Your directives may leak, be careful! Be nice to the garbage collector.
  • 29. Memory leaks If an object owns a reference to the DOM element, you must remove it when the directive is removed from the DOM. scope.$on('$destroy', function() { this._element = null; }.bind(this)); Also remove event listeners!
  • 30. Memory leaks ● Mobile devices have less memory than desktop computers ● Hybrid apps may be open for a very long time ● Even a small memory leak may be disastrous!
  • 31. Chrome Timeline Detect memory leaks. Compare state before and after leaking action. Number of nodes should be same when returning to original state.
  • 32. Directives in Cordova Nice way to use directives in Cordova: ● Emulate native UI components to make users feel at home. ● Utilize native APIs directly from the markup.
  • 33. Native app components ● Page navigation ● Tab bar ● Toolbar ● List view Cordova apps shouldn’t feel like web applications!
  • 34. UI components Lots of other frameworks also available: http://propertycross.com/
  • 35. Built on top of Angular ● Ionic and Onsen use AngularJS to create custom tags. ● Natural to write the app using AngularJS since it’s already loaded.
  • 36. Onsen UI ng-model Integrates with AngularJS <ons-switch ng-model=”switchState”></ons-switch> <p>State is: {{ switchState }}</p>
  • 37. Onsen UI ng-model Works like a checkbox:
  • 38. Components example ● Sample Sushifinder app ● Gets position with $geolocation service we created before ● Asks foursquare API for nearby sushi restaurants https://github.com/argelius/ionic-sushifinder
  • 40. Ionic <ion-navbar> ... </ion-navbar>
  • 41. Ionic <ion-list> <ion-item> ... </ion-item> ... </ion-list>
  • 42. Ionic <ion-tabs> <ion-tab icon=”icon ion-search” ></ion-tab> ... </ion-tabs>
  • 43. Onsen UI <ons-toolbar> ... </ons-toolbar>
  • 44. Onsen UI <ons-list> <ons-list-item modifier= ”chevron”> ... </ons-list-item> </ons-list>
  • 45. Onsen UI <ons-tabbar> <ons-tabbar-item page= ”find.html” > </ons-tabbar-item> ... </ons-tabbar>
  • 46. Thank you for listening!