SlideShare une entreprise Scribd logo
1  sur  46
Télécharger pour lire hors ligne
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!

Contenu connexe

Tendances

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
 

Tendances (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
 

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 

Dernier (20)

Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 

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!