SlideShare una empresa de Scribd logo
1 de 34
Descargar para leer sin conexión
<3
NATIVESCRIPT DEVELOPER DAY EUROPE
CHRIS NORING
GOOGLE DEVELOPER EXPERT
NATIVESCRIPT DEVELOPER EXPERT
@CHRIS_NORING
STRUCTURE
STRUCTURE
▸ Set up
▸ Commands & Productivity Tools
▸ Project anatomy
▸ Components & Bindings
▸ Routing
▸ Forms
▸ Http
▸ Testing
SET UP
SET UP
SET UP YOUR ANGULAR APPLICATION
▸ introducing nativescript-cli
▸ Scaffold
▸ an application tns create <App name>
▸ an Angular application
▸ tns create <App name> —ng
▸ tns create <App name> --template angular
COMMANDS & PRODUCTIVITY TOOLS
COMMANDS & PRODUCTIVITY TOOLS
USEFUL COMMANDS
▸ Runs your project, tns run <android/ios>
▸ View available commands, tns help
▸ Adds target platforms, tns platform add <android/ios>
▸ Verify connected device is recognized, tns device
▸ Downloads and installs app package on device, tns deploy
<android/ios>
VS CODE PLUGINS
COMMANDS & PRODUCTIVITY TOOLS
Scaffolds Nativescript
component ,template
Test, CSS
Code completion
Helps with imports
Snippets
Support for inline
Templates
PROJECT ANATOMY
PROJECT ANATOMY
BOOTSTRAPPING
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
Nativescript
Angular
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
PROJECT ANATOMY
ROOT MODULE - NATIVESCRIPT MODULE
@NgModule({
imports: [
NativeScriptModule,
AppRoutingModule
]
})
export class ApplicationModule {}
This one is needed
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
PROJECT ANATOMY
ROOT MODULE - ROUTING SET UP
const routes: Routes = [
{ path: "", redirectTo: "/items", pathMatch: "full" },
{ path: "items", component: ItemsComponent },
{ path: "item/:id", component: ItemDetailComponent },
];
Defining routes
@NgModule({
imports: [NativeScriptRouterModule.forRoot(Routes)],
exports: [NativeScriptRouterModule]
})
export class AppRoutingModule {}
Setting up separate routing module
@NgModule({
imports: [
NativeScriptModule,
AppRoutingModule
]
})
Importing our route module
Nativescripts version of the router
forRoot() as with Angular
COMPONENTS & BINDINGS
COMPONENTS & BINDINGS
BINDINGS
▸ string interpolation {{}}
▸ attribute binding
▸ banana in a box
▸ event binding
INTERPOLATION
COMPONENTS & BINDINGS
<Label [text]=“{{test | pipe }}”></Label>
ATTRIBUTE BINDING
<Label [text]=“test”></Label>
@Component({
template : `
<StackLayout class="page">
<Label [text]="test"></Label>
</StackLayout>
`
})
export class TestComponent {
test ="test me"
}
EVENT BINDING
@Component({
template : `
<StackLayout class="page">
<Label (tap)=“tapMe()” [text]="test"></Label>
</StackLayout>
`
})
export class TestComponent {
test ="test me"
tapMe() { }
}
COMPONENTS & BINDINGS
BANANA IN A BOX
<StackLayout class=“page">
<TextField [(ngModel)]=“product”></TextField>
</StackLayout>
@Component({})
export class ProductComponent {
product =“”
}
@NgModule({
bootstrap: [
AppComponent
],
imports: [
NativeScriptFormsModule,
})
COMPONENTS & BINDINGS
BASIC COMPONENTS
COMPONENTS & BINDINGS
<Switch></Switch> Radio button
<Label></Label> Span, free text
<ListView></ListView> UL and LI
<TextField></TextField> <input type=“text”>
<Button></Button> <button></button>
<Image></Image> <img>
Check box
Missing
ROUTING
ROUTING
ROUTING - COMPONENT BASED
<Label pageTransition="flip" [nsRouterLink]="['/item', item.id]" [text]="item.name"
class="list-group-item"></Label>
same ol router link prefixed with ns
<router-outlet></router-outlet> where to render the content
ROUTING
ROUTING - PAGE BASED
<page-router-outlet></page-router-outlet> One per app
<ActionBar title="My App" class="action-bar">
</ActionBar>
Native navigation, back
Programmatic navigationflipToNextPage() {
this.routerExtensions.navigate(["/main"], {
transition: { name: “flip", duration: 2000, curve: “linear" }
});
} You change the entire page content
FORMS
FORMS
TEMPLATE FORMS
<Button *ngIf="usernameModel.valid && passwordModel.valid"
(tap)="Save()"
text=“Save">
</Button>
Show ‘save’ button if both
fields are valid
ngForm is missing, which is
why we do this instead, per field
@NgModule({
imports: [
NativeScriptFormsModule,
]
})
<TextField required
#usernameModel="ngModel"
[(ngModel)]="username" >
</TextField>
<TextField required
#passwordModel="ngModel"
[(ngModel)]="password" >
</TextField>
Define the fields
FORMS
REACTIVE FORMS
constructor(
private formBuilder: FormBuilder) {
this.form = this.fb.group({
"name": ["", [Validators.required]]
});
}
Creating our form and fields
@NgModule({
imports: [
ReactiveFormsModule,
]
})
<StackLayout [formGroup]="form">
<TextField formControlName="name"></TextField>
<Label text="{{ form.get('name').value }}"></Label>
<Label text="Name value {{ form.get('name').status | json }}"></Label>
<Label text="Name status {{ form.value | json }}"></Label>
<Label text="Form status {{ form.status | json }}"></Label>
</StackLayout>
HTTP
HTTP
PROMISE BASED HTTP
var http = require('http');
http.getString(“url”)
.then(
(str) => console.log(str),
(err) => console.error(err)
);
http.getJSON(“url")
.then(
(json) => console.log(json),
(err) => console.error(err)
)
http.getImage(“path-to-file.png“)
.then(
(image) => console.log(image),
(err) => console.error(err)
)
http.getFile(“path-to-file.txt“)
.then(
(file) => console.log(file),
(err) => console.error(err)
)
HTTP
ANGULAR HTTP import { NativeScriptHttpModule }
from ‘nativescript-angular';
@NgModule({
imports : [.NativeScriptHttpModule ]
})
export class AppModule {}
import { Http } from '@angular/http';
class ProductService {
constructor(private http: Http) { }
getProducts() {
return this.http.get("url")
.map(result => JSON.parse(result.json()))
}
}
import 'rxjs/add/operator/map';
Inject Http service
Apply operators
TESTING
TEST
SET UP & RUN TESTING
tns test init Creates app/tests, not in release builds
Creates a sample test
Installs the nativescript-unit-test-runner
npm i @types/jasmine --save-dev Install TypeScript typings
tns test <ios/android>
Run the tests
tns test <ios/android> --watch Run tests on code change
Generates component + test
TEST
TEST THE COMPONENTimport { TestBed, inject } from '@angular/core/testing';
import { ProductDetailComponent } from './product-detail.component';
describe('a product-detail component', () => {
let component: ProductDetailComponent;
});
Suite
Set upbeforeEach(() => {
TestBed.configureTestingModule({
providers: [
ProductDetailComponent
]
});
});
Set upbeforeEach(inject([ProductDetailComponent], (ProductDetailComponent) => {
component = ProductDetailComponent;
}));
Testit('should have an instance', () => {
expect(component).toBeDefined();
});
NGZONE
NGZONE
CHANGE DETECTION NOT PICKED UP
Programmatically add view children
Using the FPS component
Changes are not picked up
Use NgZone
import {NgZone} from ‘@angular/core’;
@Component({})
export class SomeComponent {
constructor( private zone: NgZone ) {
}
doChange() {
this.zone.run(() => { this.prop = “new value”; })
}
}
SUMMARY
SUMMARY
WE HAVE COVERED
▸ Set Up
▸ Components & Bindings
▸ Forms
▸ Routing
▸ Testing
▸ Http
▸ There are minor differences
▸ Nativescript truly embraces Angular
@chris_noring
THANK YOU

Más contenido relacionado

La actualidad más candente

How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in reactBOSC Tech Labs
 
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)Ontico
 
[AngularJS] From Angular to Mobile in 30 minutes
[AngularJS] From Angular to Mobile in 30 minutes[AngularJS] From Angular to Mobile in 30 minutes
[AngularJS] From Angular to Mobile in 30 minutesGlobant
 
Protocol-Oriented Networking
Protocol-Oriented NetworkingProtocol-Oriented Networking
Protocol-Oriented NetworkingMostafa Amer
 
Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2DreamLab
 
A (very) opinionated guide to MSBuild and Project Files
A (very) opinionated guide to MSBuild and Project FilesA (very) opinionated guide to MSBuild and Project Files
A (very) opinionated guide to MSBuild and Project FilesDavid Wengier
 
Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019David Wengier
 
Migrating from Flux to Redux. Why and how.
Migrating from Flux to Redux. Why and how.Migrating from Flux to Redux. Why and how.
Migrating from Flux to Redux. Why and how.Astrails
 
The Ring programming language version 1.5.2 book - Part 44 of 181
The Ring programming language version 1.5.2 book - Part 44 of 181The Ring programming language version 1.5.2 book - Part 44 of 181
The Ring programming language version 1.5.2 book - Part 44 of 181Mahmoud Samir Fayed
 
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptGuy Royse
 
Javascript Promises/Q Library
Javascript Promises/Q LibraryJavascript Promises/Q Library
Javascript Promises/Q Libraryasync_io
 
Intro to Redux | DreamLab Academy #3
Intro to Redux | DreamLab Academy #3 Intro to Redux | DreamLab Academy #3
Intro to Redux | DreamLab Academy #3 DreamLab
 
Appengine Java Night #2b
Appengine Java Night #2bAppengine Java Night #2b
Appengine Java Night #2bShinichi Ogawa
 
Introduction to ReactJS and Redux
Introduction to ReactJS and ReduxIntroduction to ReactJS and Redux
Introduction to ReactJS and ReduxBoris Dinkevich
 

La actualidad más candente (20)

Rxjs marble-testing
Rxjs marble-testingRxjs marble-testing
Rxjs marble-testing
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in react
 
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
 
Rxjs vienna
Rxjs viennaRxjs vienna
Rxjs vienna
 
Advanced redux
Advanced reduxAdvanced redux
Advanced redux
 
[AngularJS] From Angular to Mobile in 30 minutes
[AngularJS] From Angular to Mobile in 30 minutes[AngularJS] From Angular to Mobile in 30 minutes
[AngularJS] From Angular to Mobile in 30 minutes
 
Protocol-Oriented Networking
Protocol-Oriented NetworkingProtocol-Oriented Networking
Protocol-Oriented Networking
 
Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2
 
Redux vs Alt
Redux vs AltRedux vs Alt
Redux vs Alt
 
A (very) opinionated guide to MSBuild and Project Files
A (very) opinionated guide to MSBuild and Project FilesA (very) opinionated guide to MSBuild and Project Files
A (very) opinionated guide to MSBuild and Project Files
 
Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019
 
Migrating from Flux to Redux. Why and how.
Migrating from Flux to Redux. Why and how.Migrating from Flux to Redux. Why and how.
Migrating from Flux to Redux. Why and how.
 
The Ring programming language version 1.5.2 book - Part 44 of 181
The Ring programming language version 1.5.2 book - Part 44 of 181The Ring programming language version 1.5.2 book - Part 44 of 181
The Ring programming language version 1.5.2 book - Part 44 of 181
 
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
 
Reduxing like a pro
Reduxing like a proReduxing like a pro
Reduxing like a pro
 
Rxjs swetugg
Rxjs swetuggRxjs swetugg
Rxjs swetugg
 
Javascript Promises/Q Library
Javascript Promises/Q LibraryJavascript Promises/Q Library
Javascript Promises/Q Library
 
Intro to Redux | DreamLab Academy #3
Intro to Redux | DreamLab Academy #3 Intro to Redux | DreamLab Academy #3
Intro to Redux | DreamLab Academy #3
 
Appengine Java Night #2b
Appengine Java Night #2bAppengine Java Night #2b
Appengine Java Night #2b
 
Introduction to ReactJS and Redux
Introduction to ReactJS and ReduxIntroduction to ReactJS and Redux
Introduction to ReactJS and Redux
 

Similar a Nativescript angular

Hidden Docs in Angular
Hidden Docs in AngularHidden Docs in Angular
Hidden Docs in AngularYadong Xie
 
A re introduction to webpack - reactfoo - mumbai
A re introduction to webpack - reactfoo - mumbaiA re introduction to webpack - reactfoo - mumbai
A re introduction to webpack - reactfoo - mumbaiPraveen Puglia
 
Spicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QASpicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QAAlban Gérôme
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensionserwanl
 
Unit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon GaliciaUnit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon GaliciaRobot Media
 
2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability
2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability
2008 - TechDays PT: WCF, JSON and AJAX for performance and manageabilityDaniel Fisher
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCpootsbook
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Michelangelo van Dam
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Michelangelo van Dam
 
Compatibility Detector Tool of Chrome extensions
Compatibility Detector Tool of Chrome extensionsCompatibility Detector Tool of Chrome extensions
Compatibility Detector Tool of Chrome extensionsKai Cui
 
Angular JS2 Training Session #2
Angular JS2 Training Session #2Angular JS2 Training Session #2
Angular JS2 Training Session #2Paras Mendiratta
 
Let's play with adf 3.0
Let's play with adf 3.0Let's play with adf 3.0
Let's play with adf 3.0Eugenio Romano
 
Seven Peaks Speaks - Compose Screenshot Testing Made Easy
Seven Peaks Speaks - Compose Screenshot Testing Made EasySeven Peaks Speaks - Compose Screenshot Testing Made Easy
Seven Peaks Speaks - Compose Screenshot Testing Made EasySeven Peaks Speaks
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomerzefhemel
 
Connect.js - Exploring React.Native
Connect.js - Exploring React.NativeConnect.js - Exploring React.Native
Connect.js - Exploring React.Nativejoshcjensen
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosIgor Sobreira
 
XML-Free Programming
XML-Free ProgrammingXML-Free Programming
XML-Free ProgrammingStephen Chin
 
Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4DEVCON
 

Similar a Nativescript angular (20)

Hidden Docs in Angular
Hidden Docs in AngularHidden Docs in Angular
Hidden Docs in Angular
 
A re introduction to webpack - reactfoo - mumbai
A re introduction to webpack - reactfoo - mumbaiA re introduction to webpack - reactfoo - mumbai
A re introduction to webpack - reactfoo - mumbai
 
Spicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QASpicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QA
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
 
Unit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon GaliciaUnit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon Galicia
 
2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability
2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability
2008 - TechDays PT: WCF, JSON and AJAX for performance and manageability
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 
mobl
moblmobl
mobl
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
 
Compatibility Detector Tool of Chrome extensions
Compatibility Detector Tool of Chrome extensionsCompatibility Detector Tool of Chrome extensions
Compatibility Detector Tool of Chrome extensions
 
Angular JS2 Training Session #2
Angular JS2 Training Session #2Angular JS2 Training Session #2
Angular JS2 Training Session #2
 
Let's play with adf 3.0
Let's play with adf 3.0Let's play with adf 3.0
Let's play with adf 3.0
 
Seven Peaks Speaks - Compose Screenshot Testing Made Easy
Seven Peaks Speaks - Compose Screenshot Testing Made EasySeven Peaks Speaks - Compose Screenshot Testing Made Easy
Seven Peaks Speaks - Compose Screenshot Testing Made Easy
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomer
 
Connect.js - Exploring React.Native
Connect.js - Exploring React.NativeConnect.js - Exploring React.Native
Connect.js - Exploring React.Native
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazos
 
XML-Free Programming
XML-Free ProgrammingXML-Free Programming
XML-Free Programming
 
Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4
 

Más de Christoffer Noring (20)

Azure signalR
Azure signalRAzure signalR
Azure signalR
 
Game dev 101 part 3
Game dev 101 part 3Game dev 101 part 3
Game dev 101 part 3
 
Game dev 101 part 2
Game dev 101   part 2Game dev 101   part 2
Game dev 101 part 2
 
Game dev workshop
Game dev workshopGame dev workshop
Game dev workshop
 
Deploying your static web app to the Cloud
Deploying your static web app to the CloudDeploying your static web app to the Cloud
Deploying your static web app to the Cloud
 
IaaS with ARM templates for Azure
IaaS with ARM templates for AzureIaaS with ARM templates for Azure
IaaS with ARM templates for Azure
 
Learning Svelte
Learning SvelteLearning Svelte
Learning Svelte
 
Ng spain
Ng spainNg spain
Ng spain
 
Angular Schematics
Angular SchematicsAngular Schematics
Angular Schematics
 
Design thinking
Design thinkingDesign thinking
Design thinking
 
Keynote ijs
Keynote ijsKeynote ijs
Keynote ijs
 
Vue fundamentasl with Testing and Vuex
Vue fundamentasl with Testing and VuexVue fundamentasl with Testing and Vuex
Vue fundamentasl with Testing and Vuex
 
Ngrx slides
Ngrx slidesNgrx slides
Ngrx slides
 
Kendoui
KendouiKendoui
Kendoui
 
Rxjs ngvikings
Rxjs ngvikingsRxjs ngvikings
Rxjs ngvikings
 
Angular modules in depth
Angular modules in depthAngular modules in depth
Angular modules in depth
 
Finjs - Angular 2 better faster stronger
Finjs - Angular 2 better faster strongerFinjs - Angular 2 better faster stronger
Finjs - Angular 2 better faster stronger
 
Angular2 + rxjs
Angular2 + rxjsAngular2 + rxjs
Angular2 + rxjs
 
Angular2 rxjs
Angular2 rxjsAngular2 rxjs
Angular2 rxjs
 
Nativescript with angular 2
Nativescript with angular 2Nativescript with angular 2
Nativescript with angular 2
 

Último

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Último (20)

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

Nativescript angular

  • 1. <3 NATIVESCRIPT DEVELOPER DAY EUROPE CHRIS NORING GOOGLE DEVELOPER EXPERT NATIVESCRIPT DEVELOPER EXPERT @CHRIS_NORING
  • 2. STRUCTURE STRUCTURE ▸ Set up ▸ Commands & Productivity Tools ▸ Project anatomy ▸ Components & Bindings ▸ Routing ▸ Forms ▸ Http ▸ Testing
  • 4. SET UP SET UP YOUR ANGULAR APPLICATION ▸ introducing nativescript-cli ▸ Scaffold ▸ an application tns create <App name> ▸ an Angular application ▸ tns create <App name> —ng ▸ tns create <App name> --template angular
  • 6. COMMANDS & PRODUCTIVITY TOOLS USEFUL COMMANDS ▸ Runs your project, tns run <android/ios> ▸ View available commands, tns help ▸ Adds target platforms, tns platform add <android/ios> ▸ Verify connected device is recognized, tns device ▸ Downloads and installs app package on device, tns deploy <android/ios>
  • 7. VS CODE PLUGINS COMMANDS & PRODUCTIVITY TOOLS Scaffolds Nativescript component ,template Test, CSS Code completion Helps with imports Snippets Support for inline Templates
  • 9. PROJECT ANATOMY BOOTSTRAPPING import { platformNativeScriptDynamic } from "nativescript-angular/platform"; Nativescript Angular import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
  • 10. PROJECT ANATOMY ROOT MODULE - NATIVESCRIPT MODULE @NgModule({ imports: [ NativeScriptModule, AppRoutingModule ] }) export class ApplicationModule {} This one is needed import { NativeScriptModule } from "nativescript-angular/nativescript.module";
  • 11. PROJECT ANATOMY ROOT MODULE - ROUTING SET UP const routes: Routes = [ { path: "", redirectTo: "/items", pathMatch: "full" }, { path: "items", component: ItemsComponent }, { path: "item/:id", component: ItemDetailComponent }, ]; Defining routes @NgModule({ imports: [NativeScriptRouterModule.forRoot(Routes)], exports: [NativeScriptRouterModule] }) export class AppRoutingModule {} Setting up separate routing module @NgModule({ imports: [ NativeScriptModule, AppRoutingModule ] }) Importing our route module Nativescripts version of the router forRoot() as with Angular
  • 13. COMPONENTS & BINDINGS BINDINGS ▸ string interpolation {{}} ▸ attribute binding ▸ banana in a box ▸ event binding
  • 14. INTERPOLATION COMPONENTS & BINDINGS <Label [text]=“{{test | pipe }}”></Label> ATTRIBUTE BINDING <Label [text]=“test”></Label> @Component({ template : ` <StackLayout class="page"> <Label [text]="test"></Label> </StackLayout> ` }) export class TestComponent { test ="test me" }
  • 15. EVENT BINDING @Component({ template : ` <StackLayout class="page"> <Label (tap)=“tapMe()” [text]="test"></Label> </StackLayout> ` }) export class TestComponent { test ="test me" tapMe() { } } COMPONENTS & BINDINGS
  • 16. BANANA IN A BOX <StackLayout class=“page"> <TextField [(ngModel)]=“product”></TextField> </StackLayout> @Component({}) export class ProductComponent { product =“” } @NgModule({ bootstrap: [ AppComponent ], imports: [ NativeScriptFormsModule, }) COMPONENTS & BINDINGS
  • 17. BASIC COMPONENTS COMPONENTS & BINDINGS <Switch></Switch> Radio button <Label></Label> Span, free text <ListView></ListView> UL and LI <TextField></TextField> <input type=“text”> <Button></Button> <button></button> <Image></Image> <img> Check box Missing
  • 19. ROUTING ROUTING - COMPONENT BASED <Label pageTransition="flip" [nsRouterLink]="['/item', item.id]" [text]="item.name" class="list-group-item"></Label> same ol router link prefixed with ns <router-outlet></router-outlet> where to render the content
  • 20. ROUTING ROUTING - PAGE BASED <page-router-outlet></page-router-outlet> One per app <ActionBar title="My App" class="action-bar"> </ActionBar> Native navigation, back Programmatic navigationflipToNextPage() { this.routerExtensions.navigate(["/main"], { transition: { name: “flip", duration: 2000, curve: “linear" } }); } You change the entire page content
  • 21. FORMS
  • 22. FORMS TEMPLATE FORMS <Button *ngIf="usernameModel.valid && passwordModel.valid" (tap)="Save()" text=“Save"> </Button> Show ‘save’ button if both fields are valid ngForm is missing, which is why we do this instead, per field @NgModule({ imports: [ NativeScriptFormsModule, ] }) <TextField required #usernameModel="ngModel" [(ngModel)]="username" > </TextField> <TextField required #passwordModel="ngModel" [(ngModel)]="password" > </TextField> Define the fields
  • 23. FORMS REACTIVE FORMS constructor( private formBuilder: FormBuilder) { this.form = this.fb.group({ "name": ["", [Validators.required]] }); } Creating our form and fields @NgModule({ imports: [ ReactiveFormsModule, ] }) <StackLayout [formGroup]="form"> <TextField formControlName="name"></TextField> <Label text="{{ form.get('name').value }}"></Label> <Label text="Name value {{ form.get('name').status | json }}"></Label> <Label text="Name status {{ form.value | json }}"></Label> <Label text="Form status {{ form.status | json }}"></Label> </StackLayout>
  • 24. HTTP
  • 25. HTTP PROMISE BASED HTTP var http = require('http'); http.getString(“url”) .then( (str) => console.log(str), (err) => console.error(err) ); http.getJSON(“url") .then( (json) => console.log(json), (err) => console.error(err) ) http.getImage(“path-to-file.png“) .then( (image) => console.log(image), (err) => console.error(err) ) http.getFile(“path-to-file.txt“) .then( (file) => console.log(file), (err) => console.error(err) )
  • 26. HTTP ANGULAR HTTP import { NativeScriptHttpModule } from ‘nativescript-angular'; @NgModule({ imports : [.NativeScriptHttpModule ] }) export class AppModule {} import { Http } from '@angular/http'; class ProductService { constructor(private http: Http) { } getProducts() { return this.http.get("url") .map(result => JSON.parse(result.json())) } } import 'rxjs/add/operator/map'; Inject Http service Apply operators
  • 28. TEST SET UP & RUN TESTING tns test init Creates app/tests, not in release builds Creates a sample test Installs the nativescript-unit-test-runner npm i @types/jasmine --save-dev Install TypeScript typings tns test <ios/android> Run the tests tns test <ios/android> --watch Run tests on code change Generates component + test
  • 29. TEST TEST THE COMPONENTimport { TestBed, inject } from '@angular/core/testing'; import { ProductDetailComponent } from './product-detail.component'; describe('a product-detail component', () => { let component: ProductDetailComponent; }); Suite Set upbeforeEach(() => { TestBed.configureTestingModule({ providers: [ ProductDetailComponent ] }); }); Set upbeforeEach(inject([ProductDetailComponent], (ProductDetailComponent) => { component = ProductDetailComponent; })); Testit('should have an instance', () => { expect(component).toBeDefined(); });
  • 31. NGZONE CHANGE DETECTION NOT PICKED UP Programmatically add view children Using the FPS component Changes are not picked up Use NgZone import {NgZone} from ‘@angular/core’; @Component({}) export class SomeComponent { constructor( private zone: NgZone ) { } doChange() { this.zone.run(() => { this.prop = “new value”; }) } }
  • 33. SUMMARY WE HAVE COVERED ▸ Set Up ▸ Components & Bindings ▸ Forms ▸ Routing ▸ Testing ▸ Http ▸ There are minor differences ▸ Nativescript truly embraces Angular