Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
TDD Angular Workshop
Search
Pablo Villoslada Puigcerber
May 15, 2018
Programming
0
100
TDD Angular Workshop
Pablo Villoslada Puigcerber
May 15, 2018
Tweet
Share
More Decks by Pablo Villoslada Puigcerber
See All by Pablo Villoslada Puigcerber
Angular on Fire!
puigcerber
0
66
Introducción a Angular 2
puigcerber
0
66
Introduction to AngularJS
puigcerber
0
49
AngularJS en una hora
puigcerber
0
97
Other Decks in Programming
See All in Programming
AI & Enginnering
codelynx
0
110
それ、本当に安全? ファイルアップロードで見落としがちなセキュリティリスクと対策
penpeen
7
3.8k
AgentCoreとHuman in the Loop
har1101
5
230
AIフル活用時代だからこそ学んでおきたい働き方の心得
shinoyu
0
130
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
1
940
Automatic Grammar Agreementと Markdown Extended Attributes について
kishikawakatsumi
0
180
Implementation Patterns
denyspoltorak
0
280
「ブロックテーマでは再現できない」は本当か?
inc2734
0
900
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
140
Lambda のコードストレージ容量に気をつけましょう
tattwan718
0
110
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
170
副作用をどこに置くか問題:オブジェクト指向で整理する設計判断ツリー
koxya
1
600
Featured
See All Featured
Designing for Performance
lara
610
70k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
72
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
110
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.7k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
200
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
240
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Building an army of robots
kneath
306
46k
Building Applications with DynamoDB
mza
96
6.9k
Between Models and Reality
mayunak
1
180
Deep Space Network (abreviated)
tonyrice
0
47
How to Talk to Developers About Accessibility
jct
2
130
Transcript
TDD Workshop Pablo Villoslada Puigcerber
https://speakerdeck.com/puigcerber https://github.com/Puigcerber/ tdd-angular-workshop
TypeScript
Static typed language function sayHello(name: string): string { return `Hello
${name}!`; } const person: object = {}; let age: number;
Class based programming class Angular { constructor() {} }
Decorators @Component({ selector: 'example-component', template: '<div>I am a component!</div>' })
class ExampleComponent { constructor() {} }
Components
Architecture <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head>
<body> <app-root></app-root> </body> </html>
Displaying data import { Component } from '@angular/core'; @Component({ selector:
'app-root', template: '<h1>{{title}}</h1>' }) export class AppComponent { title = 'TDD Workshop'; }
Lifecycle hooks class Lifecycle implements OnInit, OnDestroy { ngOnInit() {
console.log('on init'); } ngOnDestroy() { console.log('on destroy'); } }
Specs 1 to 4
Directives
Attribute directives <button type="button" class="btn" [ngClass]="{'btn-primary': true, 'btn-secondary': false}"> Send
</button>
Structural directives <ul *ngIf="items"> <li *ngFor="let item of items; index
as i"> {{ i }} - {{ item.name }} </li> </ul>
Pipes
Built-in pipes {{ a }}<!-- 0.189 --> {{ a |
currency }}<!-- $0.19 --> {{ a | currency:’EUR' }}<!-- €0.19 --> {{ a | currency:’USD':'code' }}<!-- USD0.19 -->
Specs 5 to 8
Services
@Injectable() import { Injectable } from '@angular/core'; @Injectable({ providedIn: MyModule,
}) export class InjectableService { }
Inject a service export class DIComponent { constructor(private http: HttpClient)
{ } ngOnInit() { this.http.get(''); } }
Observables
Subscribing const myObservable = Observable.of(1, 2, 3); myObservable.subscribe( x =>
console.log('Next value: ' + x), err => console.error('Error: ' + err), () => console.log('Complete!') );
RxJS Operators import { fromEvent } from 'rxjs'; import {
filter, map, tap } from 'rxjs/operators'; const subscription = fromEvent(document, 'keypress') .pipe( tap(console.log), filter(e => e.key === 'a'), map(e => e.keyCode) ).subscribe(console.log);
Specs 9 to 16
Router
Configuration export const routes: Routes = [ { path: 'main',
component: MainComponent } ]; @NgModule({ imports: [RouterModule.forRoot(routes) ], exports: [RouterModule] }) export class AppRoutingModule { }
Router directives <nav> <a routerLink="/items">Items</a> <a [routerLink]="['items', '1']">Item 1</a> </nav>
<router-outlet></router-outlet>
Activated route class RoutedComponent { constructor( private route: ActivatedRoute )
{ const id = route.paramMap.pipe( map((params: ParamMap) => params.get(('id'))) ); } }
Specs 17 to 21
Component interaction
Dumb component @Component({ selector: 'btn-dumb', template: `<button (click)="onClick()">{{label}}</button>` }) export
class DumbComponent{ @Input() label; @Output() dumb = new EventEmitter(); onClick() { this.dumb.emit('dumb'); } }
Smart component @Component({ selector: 'smart', template: ` <btn-dumb [label]="label" (dumb)="onDumb($event)">
</btn-dumb>` }) export class SmartComponent{ label = 'Click'; onDumb(event) { console.log(event); } }
Specs 22 to 29