SlideShare a Scribd company logo
1 of 51
a web of applications
kasper reijnders
01 introduction tijd (minuten) 1-3
02 why this subject tijd (minuten) 5-10
03 summarize tijd (minuten) 2-5
04 angular tijd (minuten) 10-20
tonight
introduction
Kasper Reijnders
○ fronteer
○ scout
○ incentronaut
why this subject
website
○ using CMS
○ basic frontend functionality
○lightbox
○search
○sharing
○etc…
○ knmg.nl / incentro.com
web apps
○ using content from some repository
○ single page applications
○ advanced frontend
○multiple components
○ facebook.com / twitter.com / airbnb.com
combined
○ apps integrated in site
○ used for ‘difficult’ content / calculations /
checks
○ anwb.nl / unive.nl / snsbank.nl
angular
angular
○ web apps
○ integrated web apps
angular
○ version 1.x
○ version 2.x and above
○next version will be 4.x
angular > 2.x
○ Modular
○components and services
○ TypeScript
○ Annotations
typescript
import {Goal} from "../types/goal";
export class ThemeService {
private goal: Goal;
constructor() {
}
}
export class Goal {
title: string;
status: Array<number> | boolean;
planned?: boolean;
}
typescript / es6
function test(i) {
return i + 2;
}
let test = i => i + 2
code
components
ngmodule
input and output
services
pipes
directives
templates
component
import { Component } from '@angular/core';
@Component({
selector: 'batman',
template: '<h1>{{name}}</h1>'
})
export class BatmanComponent {
name: string = 'Batman';
hasParents: boolean = false;
}
component
import { Component } from '@angular/core';
@Component({
selector: 'batman',
template: '<h1>{{name}}</h1>'
})
export class BatmanComponent {
name: string = 'Batman';
hasParents: boolean = false;
}
component
import { Component } from '@angular/core';
@Component({
selector: 'batman',
template: '<h1>{{name}}</h1>'
})
export class BatmanComponent {
name: string = 'Batman';
hasParents: boolean = false;
}
component
import { Component } from '@angular/core';
@Component({
selector: 'batman',
template: '<h1>{{name}}</h1>'
})
export class BatmanComponent {
name: string = 'Batman';
hasParents: boolean = false;
}
module
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BatmanComponent } from './batman.component';
@NgModule({
imports: [
BrowserModule
],
declarations: [
BatmanComponent
],
bootstrap: [ BatmanComponent ]
})
export class EverythingIsAwesomeApp { }
module
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BatmanComponent } from './batman.component';
@NgModule({
imports: [
BrowserModule
],
declarations: [
BatmanComponent
],
bootstrap: [ BatmanComponent ]
})
export class EverythingIsAwesomeApp { }
module
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BatmanComponent } from './batman.component';
@NgModule({
imports: [
BrowserModule
],
declarations: [
BatmanComponent
],
bootstrap: [ BatmanComponent ]
})
export class EverythingIsAwesomeApp { }
module
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BatmanComponent } from './batman.component';
@NgModule({
imports: [
BrowserModule
],
declarations: [
BatmanComponent
],
bootstrap: [ BatmanComponent ]
})
export class EverythingIsAwesomeApp { }
module
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BatmanComponent } from './batman.component';
@NgModule({
imports: [
BrowserModule
],
declarations: [
BatmanComponent
],
bootstrap: [ BatmanComponent ]
})
export class EverythingIsAwesomeApp { }
module
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BatmanComponent } from './batman.component';
import { BatMobileComponent } from './batmobile.component';
@NgModule({
imports: [
BrowserModule
],
declarations: [
BatmanComponent, BatMobileComponent
],
bootstrap: [ BatmanComponent ]
})
export class EverythingIsAwesomeApp { }
input and output
import { Component, Input } from '@angular/core';
@Component({
selector: 'batmobile',
template: '<div>{{driver}}</div>'
})
export class BatMobileComponent {
@Input()
driver: string;
}
input and output
import { Component } from '@angular/core';
@Component({
selector: 'batman',
template: '<batmobile [driver]="name"></batmobile>'
})
export class BatmanComponent {
name: string = 'Batman';
hasParents: boolean = false;
}
services
import { Injectable } from '@angular/core';
import { Car } from 'car';
import { CARS } from 'CARS.MOCK';
@Injectable()
export class BatmobileService {
constructor() {}
getCarPark(): Promise<Car[]> {
return Promise.resolve(CARS); // this can be replaced with a REST call
}
getCarByDriver(driver: string): Promise<Car> {
return this.getCarPark().then((cars) => {
return cars.find(car => car.driver === driver);
});
}
}
services
import { Component, Input } from '@angular/core';
@Component({
selector: 'batmobile',
template: '<div>{{driver}}</div>'
})
export class BatMobileComponent {
@Input()
driver: string;
}
services
import { Component, Input, OnInit } from '@angular/core';
import { BatmobileService } from 'batmobileservice';
@Component({
selector: 'batmobile',
template: '<div>{{driver}}</div>'
})
export class BatMobileComponent implements ngOnInit {
@Input()
driver: string;
constructor(private batmobileService: BatmobileService) {}
ngOnInit() {
// ...
}
}
services
...
constructor(private batmobileService: BatmobileService) {}
ngOnInit() {
this.batmobileService.getCarByDriver(this.driver).then((car) => {
this.car = car
});
}
...
pipes
{{ someValue | pipe }}
{{ birthday | date:'fullDate' | uppercase }}
{{ users | filter: 'name' }}
directives
1. Components
2. Structural directives
3. Attribute directives
structural directives
*ngFor
*ngIf
[ngSwitch]
*ngSwitchCase
*ngSwitchDefault
asterisk
<p *ngIf="condition">Our heroes are true!</p>
<template [ngIf]="condition">
<p>Our heroes are true!</p>
</template>
attribute directives
<div [style.background]="'lime'"> some </div>
<p myHighlight [highlightColor]="color"> color</p>
<p [myHighlight]="color">Highlight me!</p>
template options
<input [value]="firstName"> Binds property value to the result of expression firstName.
<div [attr.role]="myAriaRole"> Binds attribute role to the result of expression myAriaRole.
<div [class.extra-sparkle]="isDelightful"> Binds the presence of the CSS class extra-sparkle on the
element to the truthiness of the expression isDelightful.
<div [style.width.px]="mySize"> Binds style property width to the result of expression mySize
in pixels. Units are optional.
<button (click)="readRainbow($event)"> Calls method readRainbow when a click event is triggered on
this button element (or its children) and passes in the event
object.
<my-cmp [(title)]="name"> Sets up two-way data binding. Equivalent to: <my-cmp
[title]="name" (titleChange)="name=$event">
<p>Card No.: {{cardNumber |
myCardNumberFormatter}}</p>
Transforms the current value of expression cardNumber via
the pipe called myCardNumberFormatter.
<p>Employer: {{employer?.companyName}}</p> The safe navigation operator (?) means that the employer
field is optional and if undefined, the rest of the expression
should be ignored.
<p>Hello {{superHero}}</p> Binds text content to an interpolated string, for example,
"Hello Seabiscuit".
template options
angularjs
components
ngmodule
input and output
services
pipes
directives
templates
tips
use angular-cli to jumpstart development -> https://cli.angular.io/
have 1 functionality per file
divide data and function
make reusable components
use folders per type
- batman-project/
- src/scripts/
- components/
- directives/
- services/
- types/
- main.ts
Jan 2017 - a web of applications (angular 2)

More Related Content

What's hot

Scala Self Types by Gregor Heine, Principal Software Engineer at Gilt
Scala Self Types by Gregor Heine, Principal Software Engineer at GiltScala Self Types by Gregor Heine, Principal Software Engineer at Gilt
Scala Self Types by Gregor Heine, Principal Software Engineer at Gilt
Gilt Tech Talks
 

What's hot (20)

Angular - injection tokens & Custom libraries
Angular - injection tokens & Custom librariesAngular - injection tokens & Custom libraries
Angular - injection tokens & Custom libraries
 
Ngrx meta reducers
Ngrx meta reducersNgrx meta reducers
Ngrx meta reducers
 
Express: A Jump-Start
Express: A Jump-StartExpress: A Jump-Start
Express: A Jump-Start
 
MVC-RS par Grégoire Lhotelier
MVC-RS par Grégoire LhotelierMVC-RS par Grégoire Lhotelier
MVC-RS par Grégoire Lhotelier
 
Angular genericforms2
Angular genericforms2Angular genericforms2
Angular genericforms2
 
Angular2 with TypeScript
Angular2 with TypeScript Angular2 with TypeScript
Angular2 with TypeScript
 
Angular 2 - The Next Framework
Angular 2 - The Next FrameworkAngular 2 - The Next Framework
Angular 2 - The Next Framework
 
Introduction to Angular2
Introduction to Angular2Introduction to Angular2
Introduction to Angular2
 
The Road to Native Web Components
The Road to Native Web ComponentsThe Road to Native Web Components
The Road to Native Web Components
 
Angular 2: What's New?
Angular 2: What's New?Angular 2: What's New?
Angular 2: What's New?
 
Angular Dependency Injection
Angular Dependency InjectionAngular Dependency Injection
Angular Dependency Injection
 
CocoaHeads Paris - CATransaction: What the flush?!
CocoaHeads Paris - CATransaction: What the flush?!CocoaHeads Paris - CATransaction: What the flush?!
CocoaHeads Paris - CATransaction: What the flush?!
 
An introduction to Angular2
An introduction to Angular2 An introduction to Angular2
An introduction to Angular2
 
Angular 1.x in action now
Angular 1.x in action nowAngular 1.x in action now
Angular 1.x in action now
 
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
 
Architecture for scalable Angular applications
Architecture for scalable Angular applicationsArchitecture for scalable Angular applications
Architecture for scalable Angular applications
 
Angular performance improvments
Angular performance improvmentsAngular performance improvments
Angular performance improvments
 
Get together on getting more out of typescript &amp; angular 2
Get together on getting more out of typescript &amp; angular 2Get together on getting more out of typescript &amp; angular 2
Get together on getting more out of typescript &amp; angular 2
 
Scala Self Types by Gregor Heine, Principal Software Engineer at Gilt
Scala Self Types by Gregor Heine, Principal Software Engineer at GiltScala Self Types by Gregor Heine, Principal Software Engineer at Gilt
Scala Self Types by Gregor Heine, Principal Software Engineer at Gilt
 
Workshop 24: React Native Introduction
Workshop 24: React Native IntroductionWorkshop 24: React Native Introduction
Workshop 24: React Native Introduction
 

Similar to Jan 2017 - a web of applications (angular 2)

What is your money doing?
What is your money doing?What is your money doing?
What is your money doing?
Alfonso Fernández
 

Similar to Jan 2017 - a web of applications (angular 2) (20)

Building a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web ServicesBuilding a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web Services
 
Itsjustangular
ItsjustangularItsjustangular
Itsjustangular
 
angular fundamentals.pdf angular fundamentals.pdf
angular fundamentals.pdf angular fundamentals.pdfangular fundamentals.pdf angular fundamentals.pdf
angular fundamentals.pdf angular fundamentals.pdf
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
 
Web components with Angular
Web components with AngularWeb components with Angular
Web components with Angular
 
Angular 2 Unit Testing.pptx
Angular 2 Unit Testing.pptxAngular 2 Unit Testing.pptx
Angular 2 Unit Testing.pptx
 
Meetup SkillValue - Angular 6 : Bien démarrer son application
Meetup SkillValue - Angular 6 : Bien démarrer son applicationMeetup SkillValue - Angular 6 : Bien démarrer son application
Meetup SkillValue - Angular 6 : Bien démarrer son application
 
Night Watch with QA
Night Watch with QANight Watch with QA
Night Watch with QA
 
Angular Unit Testing NDC Minn 2018
Angular Unit Testing NDC Minn 2018Angular Unit Testing NDC Minn 2018
Angular Unit Testing NDC Minn 2018
 
How React Native, Appium and me made each other shine @Frontmania 16-11-2018
How React Native, Appium and me made each other shine @Frontmania 16-11-2018How React Native, Appium and me made each other shine @Frontmania 16-11-2018
How React Native, Appium and me made each other shine @Frontmania 16-11-2018
 
How to Implement Basic Angular Routing and Nested Routing With Params in Angu...
How to Implement Basic Angular Routing and Nested Routing With Params in Angu...How to Implement Basic Angular Routing and Nested Routing With Params in Angu...
How to Implement Basic Angular Routing and Nested Routing With Params in Angu...
 
What is your money doing?
What is your money doing?What is your money doing?
What is your money doing?
 
Angular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app exampleAngular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app example
 
Stencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has ArrivedStencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has Arrived
 
Maciej Treder ''Angular Universal - a medicine for the Angular + SEO/CDN issu...
Maciej Treder ''Angular Universal - a medicine for the Angular + SEO/CDN issu...Maciej Treder ''Angular Universal - a medicine for the Angular + SEO/CDN issu...
Maciej Treder ''Angular Universal - a medicine for the Angular + SEO/CDN issu...
 
Creating custom Validators on Reactive Forms using Angular 6
Creating custom Validators on Reactive Forms using Angular 6Creating custom Validators on Reactive Forms using Angular 6
Creating custom Validators on Reactive Forms using Angular 6
 
Commit University - Exploring Angular 2
Commit University - Exploring Angular 2Commit University - Exploring Angular 2
Commit University - Exploring Angular 2
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법
 
Protocol-Oriented Programming in Swift
Protocol-Oriented Programming in SwiftProtocol-Oriented Programming in Swift
Protocol-Oriented Programming in Swift
 
Bootiful Development with Spring Boot and Angular - RWX 2018
Bootiful Development with Spring Boot and Angular - RWX 2018Bootiful Development with Spring Boot and Angular - RWX 2018
Bootiful Development with Spring Boot and Angular - RWX 2018
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 

Jan 2017 - a web of applications (angular 2)

  • 1. a web of applications kasper reijnders
  • 2. 01 introduction tijd (minuten) 1-3 02 why this subject tijd (minuten) 5-10 03 summarize tijd (minuten) 2-5 04 angular tijd (minuten) 10-20 tonight
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13. website ○ using CMS ○ basic frontend functionality ○lightbox ○search ○sharing ○etc… ○ knmg.nl / incentro.com
  • 14. web apps ○ using content from some repository ○ single page applications ○ advanced frontend ○multiple components ○ facebook.com / twitter.com / airbnb.com
  • 15. combined ○ apps integrated in site ○ used for ‘difficult’ content / calculations / checks ○ anwb.nl / unive.nl / snsbank.nl
  • 17. angular ○ web apps ○ integrated web apps
  • 18. angular ○ version 1.x ○ version 2.x and above ○next version will be 4.x
  • 19. angular > 2.x ○ Modular ○components and services ○ TypeScript ○ Annotations
  • 20.
  • 21.
  • 22. typescript import {Goal} from "../types/goal"; export class ThemeService { private goal: Goal; constructor() { } } export class Goal { title: string; status: Array<number> | boolean; planned?: boolean; }
  • 23. typescript / es6 function test(i) { return i + 2; } let test = i => i + 2
  • 25. component import { Component } from '@angular/core'; @Component({ selector: 'batman', template: '<h1>{{name}}</h1>' }) export class BatmanComponent { name: string = 'Batman'; hasParents: boolean = false; }
  • 26. component import { Component } from '@angular/core'; @Component({ selector: 'batman', template: '<h1>{{name}}</h1>' }) export class BatmanComponent { name: string = 'Batman'; hasParents: boolean = false; }
  • 27. component import { Component } from '@angular/core'; @Component({ selector: 'batman', template: '<h1>{{name}}</h1>' }) export class BatmanComponent { name: string = 'Batman'; hasParents: boolean = false; }
  • 28. component import { Component } from '@angular/core'; @Component({ selector: 'batman', template: '<h1>{{name}}</h1>' }) export class BatmanComponent { name: string = 'Batman'; hasParents: boolean = false; }
  • 29. module import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BatmanComponent } from './batman.component'; @NgModule({ imports: [ BrowserModule ], declarations: [ BatmanComponent ], bootstrap: [ BatmanComponent ] }) export class EverythingIsAwesomeApp { }
  • 30. module import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BatmanComponent } from './batman.component'; @NgModule({ imports: [ BrowserModule ], declarations: [ BatmanComponent ], bootstrap: [ BatmanComponent ] }) export class EverythingIsAwesomeApp { }
  • 31. module import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BatmanComponent } from './batman.component'; @NgModule({ imports: [ BrowserModule ], declarations: [ BatmanComponent ], bootstrap: [ BatmanComponent ] }) export class EverythingIsAwesomeApp { }
  • 32. module import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BatmanComponent } from './batman.component'; @NgModule({ imports: [ BrowserModule ], declarations: [ BatmanComponent ], bootstrap: [ BatmanComponent ] }) export class EverythingIsAwesomeApp { }
  • 33. module import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BatmanComponent } from './batman.component'; @NgModule({ imports: [ BrowserModule ], declarations: [ BatmanComponent ], bootstrap: [ BatmanComponent ] }) export class EverythingIsAwesomeApp { }
  • 34. module import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BatmanComponent } from './batman.component'; import { BatMobileComponent } from './batmobile.component'; @NgModule({ imports: [ BrowserModule ], declarations: [ BatmanComponent, BatMobileComponent ], bootstrap: [ BatmanComponent ] }) export class EverythingIsAwesomeApp { }
  • 35. input and output import { Component, Input } from '@angular/core'; @Component({ selector: 'batmobile', template: '<div>{{driver}}</div>' }) export class BatMobileComponent { @Input() driver: string; }
  • 36. input and output import { Component } from '@angular/core'; @Component({ selector: 'batman', template: '<batmobile [driver]="name"></batmobile>' }) export class BatmanComponent { name: string = 'Batman'; hasParents: boolean = false; }
  • 37. services import { Injectable } from '@angular/core'; import { Car } from 'car'; import { CARS } from 'CARS.MOCK'; @Injectable() export class BatmobileService { constructor() {} getCarPark(): Promise<Car[]> { return Promise.resolve(CARS); // this can be replaced with a REST call } getCarByDriver(driver: string): Promise<Car> { return this.getCarPark().then((cars) => { return cars.find(car => car.driver === driver); }); } }
  • 38. services import { Component, Input } from '@angular/core'; @Component({ selector: 'batmobile', template: '<div>{{driver}}</div>' }) export class BatMobileComponent { @Input() driver: string; }
  • 39. services import { Component, Input, OnInit } from '@angular/core'; import { BatmobileService } from 'batmobileservice'; @Component({ selector: 'batmobile', template: '<div>{{driver}}</div>' }) export class BatMobileComponent implements ngOnInit { @Input() driver: string; constructor(private batmobileService: BatmobileService) {} ngOnInit() { // ... } }
  • 40. services ... constructor(private batmobileService: BatmobileService) {} ngOnInit() { this.batmobileService.getCarByDriver(this.driver).then((car) => { this.car = car }); } ...
  • 41. pipes {{ someValue | pipe }} {{ birthday | date:'fullDate' | uppercase }} {{ users | filter: 'name' }}
  • 42. directives 1. Components 2. Structural directives 3. Attribute directives
  • 44. asterisk <p *ngIf="condition">Our heroes are true!</p> <template [ngIf]="condition"> <p>Our heroes are true!</p> </template>
  • 45. attribute directives <div [style.background]="'lime'"> some </div> <p myHighlight [highlightColor]="color"> color</p> <p [myHighlight]="color">Highlight me!</p>
  • 46. template options <input [value]="firstName"> Binds property value to the result of expression firstName. <div [attr.role]="myAriaRole"> Binds attribute role to the result of expression myAriaRole. <div [class.extra-sparkle]="isDelightful"> Binds the presence of the CSS class extra-sparkle on the element to the truthiness of the expression isDelightful. <div [style.width.px]="mySize"> Binds style property width to the result of expression mySize in pixels. Units are optional. <button (click)="readRainbow($event)"> Calls method readRainbow when a click event is triggered on this button element (or its children) and passes in the event object. <my-cmp [(title)]="name"> Sets up two-way data binding. Equivalent to: <my-cmp [title]="name" (titleChange)="name=$event">
  • 47. <p>Card No.: {{cardNumber | myCardNumberFormatter}}</p> Transforms the current value of expression cardNumber via the pipe called myCardNumberFormatter. <p>Employer: {{employer?.companyName}}</p> The safe navigation operator (?) means that the employer field is optional and if undefined, the rest of the expression should be ignored. <p>Hello {{superHero}}</p> Binds text content to an interpolated string, for example, "Hello Seabiscuit". template options
  • 49. tips use angular-cli to jumpstart development -> https://cli.angular.io/ have 1 functionality per file divide data and function make reusable components
  • 50. use folders per type - batman-project/ - src/scripts/ - components/ - directives/ - services/ - types/ - main.ts