SlideShare a Scribd company logo
NativeScript and Angular 2,
Sitting in a Tree
Jen Looper (Telerik DevRel)
@jenlooper
• Ph.D. … in Medieval French (13th
century prose romance FTW)
• Retrained!
• Worked in startup, nonprofit,
big corporate 14 yrs+
• A lot of side projects
ladeezfirstmedia.com
• Now DevRel@Telerik
• I’m a developer & I like mobile apps!
I like NativeScript
Angular 2 and NativeScript
Tobias Bosch Hristo Deshev
Angular 2 and NativeScript
What is NativeScript?
• A runtime for building and running native iOS,
Android, and (soon) Windows Phone apps with a
single, JavaScript code base
Angular 2 and NativeScript
• No cross
compilation
!=
• Direct access to
native APIs in JS
!=
!=
• No DOM
Why NativeScript?
• Skills reuse
• JavaScript and CSS
• Angular2
• Code reuse
• npm modules, 3rd-party iOS and Android libraries
• Easily use native APIs
• No wrappers to access native APIs
• Use native UI elements
• Open source!
• Bridge
NativeScript Android example
Output:
NativeScript iOS example
Angular 2 and NativeScript
How does this even?
JavaScript Virtual Machine
Angular 2 and NativeScript
But…who wants to write native iOS or
Android code?
Angular 2 and NativeScript
NativeScript modules
Code Modules Platform API
2016
NativeScript file module
HTTP module example
Why NativeScript + Angular 2?
• Angular 1 = a technology that relies on browser tech to
manipulate the DOM.
• NativeScript has no DOM to manipulate
• Angular 2 decoupled the Angular framework from the
DOM
• The door is open to new mobile-friendly tech to
leverage this newly decoupled framework!!
A standard {N} app snippet
<!-- main.xml -->
<page>
<StackLayout>
<Button text= "Hello World" tap= "showAlert" />
</StackLayout>
</page>
/* main.js */
var dialogs = require("ui/dialogs");
exports.showAlert = function() {
dialogs.alert({ message: "NativeScript rocks!" });
};
Same functionality, {N} + ng2
// main.ts
import {nativeScriptBootstrap} from "nativescript-angular/application";
import {Component, View} from "angular2/angular2";
import {dialogs} from "ui/dialogs";
@Component({})
@View({
directives: [],
template: `
<stack-layout>
<button
(tap)="showAlert()"
text="Hello World"></button>
</stack-layout>
`
})
class HelloPage {
showAlert() {
dialogs.alert({ message: "NativeScript rocks!" });
}
}
export function loaded() {
nativeScriptBootstrap(HelloPage, []);
}
Destination
Implementation
Abstraction
Layer
The big picture
XMLHttpRequest
<NS Module>
Native
iOS call
Native
Android call
iOS App Android App
Destination
Implementation
Abstraction
Layer
The bigger picture ({N}+NG2)
HTTP
<Angular Component>
XMLHttpRequest
<NS Module>
Native
iOS call
Native
Android call
Ajax call
iOS App Android App Web App
XMLHttpRequest
<Browser>
One syntax for all
Attribute Binding: [attribute]
Event Binding: (event)
Intercepting input: #idhandler
Conditions: *ng-if="expression"
Loops: *ng-for="expression"
Styling: [class.style1]="expression"
The difference is in the UI
Web UI != Mobile UI
Native Layouts
Absolute Dock Grid Stack Wrap
Let’s take it for a spin!
Use a template to create a sample app:
$ tns create myNewAngularApp --template
https://github.com/NativeScript/template-hello-world-ng
$ tns emulate ios
Clone a repo:
TodoMVC – git clone
https://github.com/NativeScript/sample-ng-todomvc
$ npm install
$ tns platform add ios
$ tns platform add ios
$ tns emulate ios
PocketRave
https://github.com/jlooper/pocketrave-app
Learn more & enjoy!
NativeScript.org
NativeScript Slack Community
http://bit.ly/nativescript-slack
Really useful article: http://bit.ly/n-ng2
@nativescript
@jenlooper

More Related Content

PPTX
Ignite your app development with Angular, NativeScript and Firebase
PPTX
NativeScript and Angular
PDF
NativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
PDF
NativeScript 環境のインストールとはじめてのプロジェクト実行
PPTX
PDF
The Gist of React Native
PPTX
DOC-20230427-WA0010..pptx
PPTX
React nativebeginner1
Ignite your app development with Angular, NativeScript and Firebase
NativeScript and Angular
NativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
NativeScript 環境のインストールとはじめてのプロジェクト実行
The Gist of React Native
DOC-20230427-WA0010..pptx
React nativebeginner1

Similar to Angular 2 and NativeScript (20)

PPTX
Mobile native-hacks
PPTX
Native Script Atlanta Code Camp
PPTX
Game On With NativeScript
PDF
Introduction to MonoTouch and Monodroid/Mono for Android
PPTX
Native script overview
PPTX
Electron - cross platform desktop applications made easy
PPTX
Appcelerator Titanium Intro
PDF
Golang #5: To Go or not to Go
PDF
Angular mobile angular_u
PPTX
JavaScript on the Desktop
PPTX
NCDevCon 2017 - Cross Platform Mobile Apps
PPTX
React Native
KEY
Kirin - Making Single Page Web Apps with a Native UI
PPTX
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
PDF
Desktop apps with node webkit
PPTX
The Javascript Ecosystem
PDF
Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...
PDF
Node azure
PPTX
Native script overview
PDF
Cross-Platform Native Apps with JavaScript
Mobile native-hacks
Native Script Atlanta Code Camp
Game On With NativeScript
Introduction to MonoTouch and Monodroid/Mono for Android
Native script overview
Electron - cross platform desktop applications made easy
Appcelerator Titanium Intro
Golang #5: To Go or not to Go
Angular mobile angular_u
JavaScript on the Desktop
NCDevCon 2017 - Cross Platform Mobile Apps
React Native
Kirin - Making Single Page Web Apps with a Native UI
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Desktop apps with node webkit
The Javascript Ecosystem
Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...
Node azure
Native script overview
Cross-Platform Native Apps with JavaScript
Ad

More from Jen Looper (18)

PPTX
The Last Saree: AI and Material Culture
PPTX
Computer Science for Kids: A Storytelling Approach
PPTX
Staying Fresh and Avoiding Burnout
PPTX
Sharing Code between Web and Mobile Apps
PDF
Beacons, Plants, Boxes
PPTX
Hackathon Slides
PPTX
Using Beacons in a Mobile App - IoT Nearables
PPT
Swipe Left for NativeScript
PPTX
Crafting an Adventure: The Azure Maya Mystery
PPTX
Re-Building a Tech Community - Post Pandemic!
PPTX
Building a Tech Community in Ten Easy Steps
PPTX
Becoming a Green Developer
PPTX
Azure Static Web Apps
PPTX
Creating a Great Workshop
PPTX
The Ethics of Generative AI: A Humanist's Guide
PPTX
Zero to Hipster with the M.I.K.E. Stack
PPTX
Telerik AppBuilder, Estimote Beacons, and the IoT - Presentation for TelerikNEXT
PPTX
Telerik AppBuilder Presentation for TelerikNEXT Conference
The Last Saree: AI and Material Culture
Computer Science for Kids: A Storytelling Approach
Staying Fresh and Avoiding Burnout
Sharing Code between Web and Mobile Apps
Beacons, Plants, Boxes
Hackathon Slides
Using Beacons in a Mobile App - IoT Nearables
Swipe Left for NativeScript
Crafting an Adventure: The Azure Maya Mystery
Re-Building a Tech Community - Post Pandemic!
Building a Tech Community in Ten Easy Steps
Becoming a Green Developer
Azure Static Web Apps
Creating a Great Workshop
The Ethics of Generative AI: A Humanist's Guide
Zero to Hipster with the M.I.K.E. Stack
Telerik AppBuilder, Estimote Beacons, and the IoT - Presentation for TelerikNEXT
Telerik AppBuilder Presentation for TelerikNEXT Conference
Ad

Recently uploaded (20)

PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
Geodesy 1.pptx...............................................
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
DOCX
573137875-Attendance-Management-System-original
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
PPT on Performance Review to get promotions
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Embodied AI: Ushering in the Next Era of Intelligent Systems
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Geodesy 1.pptx...............................................
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
CYBER-CRIMES AND SECURITY A guide to understanding
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
OOP with Java - Java Introduction (Basics)
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Automation-in-Manufacturing-Chapter-Introduction.pdf
573137875-Attendance-Management-System-original
bas. eng. economics group 4 presentation 1.pptx
Internet of Things (IOT) - A guide to understanding
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPT on Performance Review to get promotions
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf

Angular 2 and NativeScript

  • 1. NativeScript and Angular 2, Sitting in a Tree Jen Looper (Telerik DevRel) @jenlooper
  • 2. • Ph.D. … in Medieval French (13th century prose romance FTW) • Retrained! • Worked in startup, nonprofit, big corporate 14 yrs+ • A lot of side projects ladeezfirstmedia.com • Now DevRel@Telerik
  • 3. • I’m a developer & I like mobile apps!
  • 8. What is NativeScript? • A runtime for building and running native iOS, Android, and (soon) Windows Phone apps with a single, JavaScript code base
  • 10. • No cross compilation != • Direct access to native APIs in JS != != • No DOM
  • 11. Why NativeScript? • Skills reuse • JavaScript and CSS • Angular2 • Code reuse • npm modules, 3rd-party iOS and Android libraries • Easily use native APIs • No wrappers to access native APIs • Use native UI elements • Open source!
  • 16. How does this even?
  • 19. But…who wants to write native iOS or Android code?
  • 24. Why NativeScript + Angular 2? • Angular 1 = a technology that relies on browser tech to manipulate the DOM. • NativeScript has no DOM to manipulate • Angular 2 decoupled the Angular framework from the DOM • The door is open to new mobile-friendly tech to leverage this newly decoupled framework!!
  • 25. A standard {N} app snippet <!-- main.xml --> <page> <StackLayout> <Button text= "Hello World" tap= "showAlert" /> </StackLayout> </page> /* main.js */ var dialogs = require("ui/dialogs"); exports.showAlert = function() { dialogs.alert({ message: "NativeScript rocks!" }); };
  • 26. Same functionality, {N} + ng2 // main.ts import {nativeScriptBootstrap} from "nativescript-angular/application"; import {Component, View} from "angular2/angular2"; import {dialogs} from "ui/dialogs"; @Component({}) @View({ directives: [], template: ` <stack-layout> <button (tap)="showAlert()" text="Hello World"></button> </stack-layout> ` }) class HelloPage { showAlert() { dialogs.alert({ message: "NativeScript rocks!" }); } } export function loaded() { nativeScriptBootstrap(HelloPage, []); }
  • 27. Destination Implementation Abstraction Layer The big picture XMLHttpRequest <NS Module> Native iOS call Native Android call iOS App Android App
  • 28. Destination Implementation Abstraction Layer The bigger picture ({N}+NG2) HTTP <Angular Component> XMLHttpRequest <NS Module> Native iOS call Native Android call Ajax call iOS App Android App Web App XMLHttpRequest <Browser>
  • 29. One syntax for all Attribute Binding: [attribute] Event Binding: (event) Intercepting input: #idhandler Conditions: *ng-if="expression" Loops: *ng-for="expression" Styling: [class.style1]="expression"
  • 30. The difference is in the UI Web UI != Mobile UI
  • 31. Native Layouts Absolute Dock Grid Stack Wrap
  • 32. Let’s take it for a spin! Use a template to create a sample app: $ tns create myNewAngularApp --template https://github.com/NativeScript/template-hello-world-ng $ tns emulate ios
  • 33. Clone a repo: TodoMVC – git clone https://github.com/NativeScript/sample-ng-todomvc $ npm install $ tns platform add ios $ tns platform add ios $ tns emulate ios PocketRave https://github.com/jlooper/pocketrave-app
  • 34. Learn more & enjoy! NativeScript.org NativeScript Slack Community http://bit.ly/nativescript-slack Really useful article: http://bit.ly/n-ng2 @nativescript @jenlooper