SlideShare una empresa de Scribd logo
1 de 46
Descargar para leer sin conexión
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!

Más contenido relacionado

La actualidad más candente

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
 
Coffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JSCoffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JSDeepu S Nath
 
The Art of AngularJS - DeRailed 2014
The Art of AngularJS - DeRailed 2014The Art of AngularJS - DeRailed 2014
The Art of AngularJS - DeRailed 2014Matt Raible
 
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 AngularSparkhound 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 OrientDBApaichon Punopas
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - IntroductionSagar Acharya
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architectureMichael He
 
AngularJS best-practices
AngularJS best-practicesAngularJS best-practices
AngularJS best-practicesHenry Tao
 
Workshop 9: BackboneJS y patrones MVC
Workshop 9: BackboneJS y patrones MVCWorkshop 9: BackboneJS y patrones MVC
Workshop 9: BackboneJS y patrones MVCVisual 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 IntroductionCarlos Morales
 
Introduction to AJAX In WordPress
Introduction to AJAX In WordPressIntroduction to AJAX In WordPress
Introduction to AJAX In WordPressCaldera 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 AngularJSArmin Vieweg
 

La actualidad más candente (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
 

Destacado

The 10 Commandments of Electromagnetic Compatibility
The 10 Commandments of Electromagnetic CompatibilityThe 10 Commandments of Electromagnetic Compatibility
The 10 Commandments of Electromagnetic CompatibilityJaymie Murray
 
Community Manager Appreciation Day 2013
Community Manager Appreciation Day 2013Community Manager Appreciation Day 2013
Community Manager Appreciation Day 2013Michael 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 VisualizationBenjamin 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 finalLora Cecere
 
Talent pipeline activation webinar
Talent pipeline activation webinarTalent pipeline activation webinar
Talent pipeline activation webinarLinkedIn
 
Presentación sobre Derechos Humanos
Presentación sobre Derechos HumanosPresentación sobre Derechos Humanos
Presentación sobre Derechos HumanosJoaquin Sanchez
 
19 plan & section of penstock
19 plan & section of  penstock19 plan & section of  penstock
19 plan & section of penstockNikhil Jaipurkar
 
風險測試
風險測試風險測試
風險測試excel2003
 
Galicia - Comenius Project
Galicia - Comenius ProjectGalicia - Comenius Project
Galicia - Comenius Projectlaborcomenius
 
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 DesignAmy Goodloe
 

Destacado (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 a SF Cordova Meetup

Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIVisual Engineering
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to AngularjsGaurav Agrawal
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular jsTamer Solieman
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development GuideNitin Giri
 
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 StudiosLearnimtactics
 
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 2014Sarah 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-phpapp01Arunangsu 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 KarmaExoLeaders.com
 

Similar a 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
AngularJsAngularJs
AngularJs
 
Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01
 
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
 

Último

Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 

Último (20)

Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 

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!