SlideShare a Scribd company logo
SPQR
Hannes Kuhlmann
Florian Bücklers
Building an Angular 2 App
@baqendcom
Speaker Question Round
Why Baqend?
Who we are
• Many years of experience in web dev
• Both frontend and backend
• Many Angular 1 projects
• Very curious about Angular 2  introduced it in a
production web platform
• What we do: developing Baqend, a serverless
backend for faster websites and apps
• Great match for Angular2 (see our Baqend+Angular 2
starter kit)
Angular 2
• A framework to build client-side applications
• Code can be written in Typescript, ES6, Dart or
JavaScript (without transpiling)
• Has an expressive template language
• Powerful data binding
• Available as release candidate 6 (08/09/2016)
Why Angular 2?
• Fixes many performance pitfalls of Angular 1
• Modern design using ES6 features, e.g.:
• Classes, Template strings
• Simplified API and clearer concepts
• Uses Typescript as the primary language for:
• Interfaces
• Type declarations
• Decorators and Annotations
Project Setup
• We use System.js to load ES6 based modules
• Also Webpack or browserify can be used
• Typescript since it is the recommended language
• Hosted on Baqend
http://spqr.app.baqend.com
Components
• Components are the main classes where most of our
code is
• Template:
• Mostly HTML with some additional instructions
• Styles are scoped to the component (similar to Web
Components)
• Component Class:
• Methods and properties that can be accessed and invoked
from the rendered page
• Metadata specified in Decorators:
• Additional instructions like styles, template and directives
Template expressions
• Model to view binding for values and properties
• View to model binding
• View to model & model to view (2-way-binding)
<div [class.active]="question.state == 'active'">
<span class="badge">{{question.votes}}</span>
<div (click)="onClick($event)"></div>
<input [(ngModel)]="value"></input>
<!-- short hand for -->
<input [ngModel]="value" (ngModel)="value = $event"></input>
Structural Directives *ngIf, *ngFor
• *ngIf conditionally renders a template
• *ngFor loops over a collection
<!-- *ngIf paragraph -->
<div *ngIf="questions">
We have some questions
</div>
<!-- [ngIf] with template -->
<template [ngIf]="questions ">
<div>
We have some questions
</div>
</template>
<div *ngFor="let question of questions">{{question.question}}</div>
Forms
• ngModel adds two-way binding between model
and input value
• ngSubmit handles form submissions
• Access to the form controller ngForm
<input type="text" [(ngModel)]="newQuestion" name="question" required>
<form (ngSubmit)="ask(newQuestion)">
<form #questionForm="ngForm" (ngSubmit)="ask(questionForm.value)">
…
<button type="submit" [disabled]="!questionForm.valid">Ask</button>
</form>
Services
• Services are useful to share common code between
different controllers.
• Services are injectable, so they can be used in any
Component / Pipe / Directive …
• Services are created by Angular when they are first
requested and are treated as singletons
@Injectable()
export class StorageService {
export class TalkComponent {
//StorageService is injected to the component by angular
constructor(private storageService:StorageService) {}
Pipes
• Pipes are template helpers to transform values
• Pipes are pure by default
• A pure pipe is only invoked if its primitive input changed
or the reference of an object changed
• Impure Pipes
• Needed if the pipe must be reevaluated when
properties of an object changed or elements of an array
are updated
• Are always evaluated (expensive)
<small>{{question.date | date:'shortTime'}}</small>
Router
• Routes are defined as URL patterns and handled by
a target component
• Matching route parameters can be accesses by
injecting the ActivatedRoute
const routes: Routes = [
{ path: 'talk/:id', component: TalkComponent }
];
export class TalkComponent {
constructor(private route: ActivatedRoute) {}
ngOnInit() {
let id = this.route.snapshot.params['id'];
}
}
Router Navigation
• The routerLink directive can be used to navigate to a
another route
• The router can be used to navigate programmatically
• Highlight active route links by setting a class
<a routerLink="/login">Login</a>
constructor(private router: Router)
navigate(talk) {
this.router.navigate(['/talk', talk.id]);
}
<a routerLink="/login" routerLinkActive="active">Login</a>
Route Subscription
• You can also subscribe to route parameter changes
• Prevents recreating and redrawing the component when
only a parameter changes
ngOnInit() {
this.sub = this.route.params.subscribe(params => {
let id = params['id'];
});
}
ngOnDestroy() {
this.sub.unsubscribe();
}
Directives
• Extend the behavior of HTML
• Most directives introduce new attributes or HTML
elements
• The controller can be exposed with exportAs
• Controller methods can be used within the
template
@Directive({
selector: '[collapse]',
exportAs: 'Collapse'
})
export class CollapseDirective {
<button type="button" (click)="navbar.toggle()"></button>
<div collapse #navbar="Collapse">
Model to directive binding
• A directive has no direct access to outer scope
• Instead model data can bind to a directive
• The directive subscribes to changes
export class CollapseDirective {
@Input() collapse:boolean;
ngOnChanges(changes: {[propKey: string]: SimpleChange}) {
if (changes.collapse) {
//changed by model
let from = changes.collapse.previousValue;
let to = changes.collapse.currentValue;
}
}
}
<div [collapse]="navbarCollapse">
Directive to model binding
• A directive has no direct access to the outer scope
• Data can be sent to the model
• And be subscribed to in the view
<div (collapse)="navbarCollapse = $event">
export class CollapseDirective {
@Output() collapse = new EventEmitter<boolean>();
toggle() {
this.expanded = !this.expanded;
this.collapse.emit(this.expanded);
}
}
Directive <-> model binding
• Binding can be two-way, similar to components:
<div [(collapse)]="navbarCollapse">
export class CollapseDirective {
@Input() collapse:boolean;
@Output() collapseChange = new EventEmitter<boolean>();
ngOnChanges(changes: {[propKey: string]: SimpleChange}) {
if (changes.collapse)
//changed by model
}
toggle() {
this.collapseChange.emit(!this.expanded);
}
}
Thank you!
{fb,hk}@baqend.com
http://www.baqend.com/guide/starters/
http://spqr.app.baqend.com

More Related Content

What's hot

Angular JS
Angular JSAngular JS
Angular JS
John Temoty Roca
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
Infragistics
 
Angular js 1.0-fundamentals
Angular js 1.0-fundamentalsAngular js 1.0-fundamentals
Angular js 1.0-fundamentals
Venkatesh Narayanan
 
AngularJS 2.0
AngularJS 2.0AngularJS 2.0
AngularJS 2.0
Boyan Mihaylov
 
Rambler.iOS #5: Разбираем Massive View Controller
Rambler.iOS #5: Разбираем Massive View ControllerRambler.iOS #5: Разбираем Massive View Controller
Rambler.iOS #5: Разбираем Massive View Controller
RAMBLER&Co
 
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
 
SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...
SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...
SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...
Sencha
 
CraftCamp for Students - Introduction to AngularJS
CraftCamp for Students - Introduction to AngularJSCraftCamp for Students - Introduction to AngularJS
CraftCamp for Students - Introduction to AngularJS
craftworkz
 
AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introduction
Tania Gonzales
 
Web component
Web componentWeb component
Web component
EngrHasanuzzamanSumo
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
Manish Shekhawat
 
Introduction to single page application with angular js
Introduction to single page application with angular jsIntroduction to single page application with angular js
Introduction to single page application with angular js
Mindfire Solutions
 
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...
Sencha
 
AngularJS with RequireJS
AngularJS with RequireJSAngularJS with RequireJS
AngularJS with RequireJS
Johannes Weber
 
5 angularjs features
5 angularjs features5 angularjs features
5 angularjs features
Alexey (Mr_Mig) Migutsky
 
AngularJS One Day Workshop
AngularJS One Day WorkshopAngularJS One Day Workshop
AngularJS One Day Workshop
Shyam Seshadri
 
Angular JS tutorial
Angular JS tutorialAngular JS tutorial
Angular JS tutorial
cncwebworld
 
Angular View Encapsulation
Angular View EncapsulationAngular View Encapsulation
Angular View Encapsulation
Jennifer Estrada
 
What Is Angular 2 | Angular 2 Tutorial For Beginners | Angular Training | Edu...
What Is Angular 2 | Angular 2 Tutorial For Beginners | Angular Training | Edu...What Is Angular 2 | Angular 2 Tutorial For Beginners | Angular Training | Edu...
What Is Angular 2 | Angular 2 Tutorial For Beginners | Angular Training | Edu...
Edureka!
 
Sexy Architecting. VIPER: MVP on steroids
Sexy Architecting. VIPER: MVP on steroidsSexy Architecting. VIPER: MVP on steroids
Sexy Architecting. VIPER: MVP on steroids
Dmytro Zaitsev
 

What's hot (20)

Angular JS
Angular JSAngular JS
Angular JS
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
 
Angular js 1.0-fundamentals
Angular js 1.0-fundamentalsAngular js 1.0-fundamentals
Angular js 1.0-fundamentals
 
AngularJS 2.0
AngularJS 2.0AngularJS 2.0
AngularJS 2.0
 
Rambler.iOS #5: Разбираем Massive View Controller
Rambler.iOS #5: Разбираем Massive View ControllerRambler.iOS #5: Разбираем Massive View Controller
Rambler.iOS #5: Разбираем Massive View Controller
 
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 
 
SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...
SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...
SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...
 
CraftCamp for Students - Introduction to AngularJS
CraftCamp for Students - Introduction to AngularJSCraftCamp for Students - Introduction to AngularJS
CraftCamp for Students - Introduction to AngularJS
 
AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introduction
 
Web component
Web componentWeb component
Web component
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
Introduction to single page application with angular js
Introduction to single page application with angular jsIntroduction to single page application with angular js
Introduction to single page application with angular js
 
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...
 
AngularJS with RequireJS
AngularJS with RequireJSAngularJS with RequireJS
AngularJS with RequireJS
 
5 angularjs features
5 angularjs features5 angularjs features
5 angularjs features
 
AngularJS One Day Workshop
AngularJS One Day WorkshopAngularJS One Day Workshop
AngularJS One Day Workshop
 
Angular JS tutorial
Angular JS tutorialAngular JS tutorial
Angular JS tutorial
 
Angular View Encapsulation
Angular View EncapsulationAngular View Encapsulation
Angular View Encapsulation
 
What Is Angular 2 | Angular 2 Tutorial For Beginners | Angular Training | Edu...
What Is Angular 2 | Angular 2 Tutorial For Beginners | Angular Training | Edu...What Is Angular 2 | Angular 2 Tutorial For Beginners | Angular Training | Edu...
What Is Angular 2 | Angular 2 Tutorial For Beginners | Angular Training | Edu...
 
Sexy Architecting. VIPER: MVP on steroids
Sexy Architecting. VIPER: MVP on steroidsSexy Architecting. VIPER: MVP on steroids
Sexy Architecting. VIPER: MVP on steroids
 

Similar to Angular 2 at solutions.hamburg

Building an Angular 2 App
Building an Angular 2 AppBuilding an Angular 2 App
Building an Angular 2 App
Felix Gessert
 
Angularjs
AngularjsAngularjs
Angularjs
Ynon Perek
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
Dilip Patel
 
Angular js 2
Angular js 2Angular js 2
Angular js 2
Ran Wahle
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
murtazahaveliwala
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
Luigi De Russis
 
"Umbraco MVC - a journey of discovery" - Lotte Pitcher
"Umbraco MVC - a journey of discovery" - Lotte Pitcher"Umbraco MVC - a journey of discovery" - Lotte Pitcher
"Umbraco MVC - a journey of discovery" - Lotte Pitcher
lottepitcher
 
Front End Development for Back End Developers - Devoxx UK 2017
 Front End Development for Back End Developers - Devoxx UK 2017 Front End Development for Back End Developers - Devoxx UK 2017
Front End Development for Back End Developers - Devoxx UK 2017
Matt Raible
 
mean stack
mean stackmean stack
mean stack
michaelaaron25322
 
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas EmbletongDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
George Nguyen
 
Knolx session
Knolx sessionKnolx session
Knolx session
Knoldus Inc.
 
Angular 2 overview in 60 minutes
Angular 2 overview in 60 minutesAngular 2 overview in 60 minutes
Angular 2 overview in 60 minutes
Loiane Groner
 
Voorhoede - Front-end architecture
Voorhoede - Front-end architectureVoorhoede - Front-end architecture
Voorhoede - Front-end architecture
Jasper Moelker
 
Asp.Net MVC 5 in Arabic
Asp.Net MVC 5 in ArabicAsp.Net MVC 5 in Arabic
Asp.Net MVC 5 in Arabic
Haitham Shaddad
 
HTML5 Refresher
HTML5 RefresherHTML5 Refresher
HTML5 Refresher
Ivano Malavolta
 
Nuxt.JS Introdruction
Nuxt.JS IntrodructionNuxt.JS Introdruction
Nuxt.JS Introdruction
David Ličen
 
C# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASPC# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASP
Mohammad Shaker
 
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Anupam Ranku
 
Strut2-Spring-Hibernate
Strut2-Spring-HibernateStrut2-Spring-Hibernate
Strut2-Spring-Hibernate
Jay Shah
 
Vue 2.0 + Vuex Router & Vuex at Vue.js
Vue 2.0 + Vuex Router & Vuex at Vue.jsVue 2.0 + Vuex Router & Vuex at Vue.js
Vue 2.0 + Vuex Router & Vuex at Vue.js
Takuya Tejima
 

Similar to Angular 2 at solutions.hamburg (20)

Building an Angular 2 App
Building an Angular 2 AppBuilding an Angular 2 App
Building an Angular 2 App
 
Angularjs
AngularjsAngularjs
Angularjs
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
 
Angular js 2
Angular js 2Angular js 2
Angular js 2
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
 
"Umbraco MVC - a journey of discovery" - Lotte Pitcher
"Umbraco MVC - a journey of discovery" - Lotte Pitcher"Umbraco MVC - a journey of discovery" - Lotte Pitcher
"Umbraco MVC - a journey of discovery" - Lotte Pitcher
 
Front End Development for Back End Developers - Devoxx UK 2017
 Front End Development for Back End Developers - Devoxx UK 2017 Front End Development for Back End Developers - Devoxx UK 2017
Front End Development for Back End Developers - Devoxx UK 2017
 
mean stack
mean stackmean stack
mean stack
 
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas EmbletongDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
 
Knolx session
Knolx sessionKnolx session
Knolx session
 
Angular 2 overview in 60 minutes
Angular 2 overview in 60 minutesAngular 2 overview in 60 minutes
Angular 2 overview in 60 minutes
 
Voorhoede - Front-end architecture
Voorhoede - Front-end architectureVoorhoede - Front-end architecture
Voorhoede - Front-end architecture
 
Asp.Net MVC 5 in Arabic
Asp.Net MVC 5 in ArabicAsp.Net MVC 5 in Arabic
Asp.Net MVC 5 in Arabic
 
HTML5 Refresher
HTML5 RefresherHTML5 Refresher
HTML5 Refresher
 
Nuxt.JS Introdruction
Nuxt.JS IntrodructionNuxt.JS Introdruction
Nuxt.JS Introdruction
 
C# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASPC# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASP
 
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
 
Strut2-Spring-Hibernate
Strut2-Spring-HibernateStrut2-Spring-Hibernate
Strut2-Spring-Hibernate
 
Vue 2.0 + Vuex Router & Vuex at Vue.js
Vue 2.0 + Vuex Router & Vuex at Vue.jsVue 2.0 + Vuex Router & Vuex at Vue.js
Vue 2.0 + Vuex Router & Vuex at Vue.js
 

Recently uploaded

Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
Requirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional SafetyRequirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional Safety
Ayan Halder
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Envertis Software Solutions
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
Drona Infotech
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
Peter Muessig
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
YousufSait3
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 

Recently uploaded (20)

Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
Requirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional SafetyRequirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional Safety
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 

Angular 2 at solutions.hamburg

  • 1. SPQR Hannes Kuhlmann Florian Bücklers Building an Angular 2 App @baqendcom Speaker Question Round
  • 3. Who we are • Many years of experience in web dev • Both frontend and backend • Many Angular 1 projects • Very curious about Angular 2  introduced it in a production web platform • What we do: developing Baqend, a serverless backend for faster websites and apps • Great match for Angular2 (see our Baqend+Angular 2 starter kit)
  • 4. Angular 2 • A framework to build client-side applications • Code can be written in Typescript, ES6, Dart or JavaScript (without transpiling) • Has an expressive template language • Powerful data binding • Available as release candidate 6 (08/09/2016)
  • 5. Why Angular 2? • Fixes many performance pitfalls of Angular 1 • Modern design using ES6 features, e.g.: • Classes, Template strings • Simplified API and clearer concepts • Uses Typescript as the primary language for: • Interfaces • Type declarations • Decorators and Annotations
  • 6. Project Setup • We use System.js to load ES6 based modules • Also Webpack or browserify can be used • Typescript since it is the recommended language • Hosted on Baqend
  • 8. Components • Components are the main classes where most of our code is • Template: • Mostly HTML with some additional instructions • Styles are scoped to the component (similar to Web Components) • Component Class: • Methods and properties that can be accessed and invoked from the rendered page • Metadata specified in Decorators: • Additional instructions like styles, template and directives
  • 9. Template expressions • Model to view binding for values and properties • View to model binding • View to model & model to view (2-way-binding) <div [class.active]="question.state == 'active'"> <span class="badge">{{question.votes}}</span> <div (click)="onClick($event)"></div> <input [(ngModel)]="value"></input> <!-- short hand for --> <input [ngModel]="value" (ngModel)="value = $event"></input>
  • 10. Structural Directives *ngIf, *ngFor • *ngIf conditionally renders a template • *ngFor loops over a collection <!-- *ngIf paragraph --> <div *ngIf="questions"> We have some questions </div> <!-- [ngIf] with template --> <template [ngIf]="questions "> <div> We have some questions </div> </template> <div *ngFor="let question of questions">{{question.question}}</div>
  • 11. Forms • ngModel adds two-way binding between model and input value • ngSubmit handles form submissions • Access to the form controller ngForm <input type="text" [(ngModel)]="newQuestion" name="question" required> <form (ngSubmit)="ask(newQuestion)"> <form #questionForm="ngForm" (ngSubmit)="ask(questionForm.value)"> … <button type="submit" [disabled]="!questionForm.valid">Ask</button> </form>
  • 12. Services • Services are useful to share common code between different controllers. • Services are injectable, so they can be used in any Component / Pipe / Directive … • Services are created by Angular when they are first requested and are treated as singletons @Injectable() export class StorageService { export class TalkComponent { //StorageService is injected to the component by angular constructor(private storageService:StorageService) {}
  • 13. Pipes • Pipes are template helpers to transform values • Pipes are pure by default • A pure pipe is only invoked if its primitive input changed or the reference of an object changed • Impure Pipes • Needed if the pipe must be reevaluated when properties of an object changed or elements of an array are updated • Are always evaluated (expensive) <small>{{question.date | date:'shortTime'}}</small>
  • 14. Router • Routes are defined as URL patterns and handled by a target component • Matching route parameters can be accesses by injecting the ActivatedRoute const routes: Routes = [ { path: 'talk/:id', component: TalkComponent } ]; export class TalkComponent { constructor(private route: ActivatedRoute) {} ngOnInit() { let id = this.route.snapshot.params['id']; } }
  • 15. Router Navigation • The routerLink directive can be used to navigate to a another route • The router can be used to navigate programmatically • Highlight active route links by setting a class <a routerLink="/login">Login</a> constructor(private router: Router) navigate(talk) { this.router.navigate(['/talk', talk.id]); } <a routerLink="/login" routerLinkActive="active">Login</a>
  • 16. Route Subscription • You can also subscribe to route parameter changes • Prevents recreating and redrawing the component when only a parameter changes ngOnInit() { this.sub = this.route.params.subscribe(params => { let id = params['id']; }); } ngOnDestroy() { this.sub.unsubscribe(); }
  • 17. Directives • Extend the behavior of HTML • Most directives introduce new attributes or HTML elements • The controller can be exposed with exportAs • Controller methods can be used within the template @Directive({ selector: '[collapse]', exportAs: 'Collapse' }) export class CollapseDirective { <button type="button" (click)="navbar.toggle()"></button> <div collapse #navbar="Collapse">
  • 18. Model to directive binding • A directive has no direct access to outer scope • Instead model data can bind to a directive • The directive subscribes to changes export class CollapseDirective { @Input() collapse:boolean; ngOnChanges(changes: {[propKey: string]: SimpleChange}) { if (changes.collapse) { //changed by model let from = changes.collapse.previousValue; let to = changes.collapse.currentValue; } } } <div [collapse]="navbarCollapse">
  • 19. Directive to model binding • A directive has no direct access to the outer scope • Data can be sent to the model • And be subscribed to in the view <div (collapse)="navbarCollapse = $event"> export class CollapseDirective { @Output() collapse = new EventEmitter<boolean>(); toggle() { this.expanded = !this.expanded; this.collapse.emit(this.expanded); } }
  • 20. Directive <-> model binding • Binding can be two-way, similar to components: <div [(collapse)]="navbarCollapse"> export class CollapseDirective { @Input() collapse:boolean; @Output() collapseChange = new EventEmitter<boolean>(); ngOnChanges(changes: {[propKey: string]: SimpleChange}) { if (changes.collapse) //changed by model } toggle() { this.collapseChange.emit(!this.expanded); } }