Slide 1

Slide 1 text

co-IT.eu GmbH Inspire To Change Gregor Woiwode @GregOnNet Angular Solid Foundations

Slide 2

Slide 2 text

Values N G U L A R Apps that users ♥ to use Apps that developers to build Community where everyone feels welcome

Slide 3

Slide 3 text

Values NGULAR Apps that users to use Apps that developers ♥ to build Community where everyone feels welcome Igor Minar Lead at project - Keynote at AngularConnect 2018, London

Slide 4

Slide 4 text

Firebase Google Cloud Platform Google Express Google Analytics +600 more … @Google N G U L A R

Slide 5

Slide 5 text

N G U L A R Clientside Rendering Serverside Rendering Mobile Native Mobile Embedded Flavours

Slide 6

Slide 6 text

Think in small building blocks N G U L A R To g g le All Prepare Workshop Hold the Workshop ToDo App Title ToDo Un-/ Complete

Slide 7

Slide 7 text

Group wisely N G U L A R T o g g le All Prepare Workshop Hold the Workshop ToDo App List Item

Slide 8

Slide 8 text

Think in features N G U L A R T o g g le All Prepare Workshop Hold the Workshop ToDo App Header ToDos

Slide 9

Slide 9 text

Components

Slide 10

Slide 10 text

Purpose C O M P O N E N T S Prepare Workshop Representation & Interaction

Slide 11

Slide 11 text

Purpose C O M P O N E N T S Representation

Slide 12

Slide 12 text

Purpose C O M P O N E N T S Interaction

Slide 13

Slide 13 text

HANDS ON Components in the wild

Slide 14

Slide 14 text

Start Application ANGULAR CLI npm start -- --open Watch out! !

Slide 15

Slide 15 text

Your Entry Point COMPONENTS app.component.(html,scss,ts,spec.ts) is the root of all good. !

Slide 16

Slide 16 text

Auto Reload ANGULAR CLI

Slide 17

Slide 17 text

Declaration COMPONENTS import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) export class AppComponent { title = 'solid-foundations'; }

Slide 18

Slide 18 text

Usage COMPONENTS index.html

Slide 19

Slide 19 text

Declaration COMPONENTS import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) export class AppComponent { title = 'solid-foundations'; }

Slide 20

Slide 20 text

Declaration COMPONENTS import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) export class AppComponent { title = 'solid-foundations'; }

Slide 21

Slide 21 text

Declaration COMPONENTS import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) export class AppComponent { title = 'solid-foundations'; }

Slide 22

Slide 22 text

Declaration COMPONENTS import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) export class AppComponent { title = 'solid-foundations'; }

Slide 23

Slide 23 text

Declaration COMPONENTS import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) export class AppComponent { title = 'solid-foundations'; }

Slide 24

Slide 24 text

HANDS ON Enhance AppComponent

Slide 25

Slide 25 text

Assign data COMPONENTS app.component.ts app.component.html @Component({ !" !!# }) export class AppComponent { title = 'solid-foundations'; todo = { text: 'Prepare 1st Workshop', isComplete: true }; } {{ todo.text }}

Slide 26

Slide 26 text

Handle events COMPONENTS app.component.ts app.component.html @Component({ !" !!# }) export class AppComponent { !" !!# show(todo) { alert(todo); } } {{ todo.text }}

Slide 27

Slide 27 text

Input Bindings COMPONENTS app.component.html {{ todo.text }} [property]="..." Let data flow into a child component

Slide 28

Slide 28 text

Output Bindings COMPONENTS app.component.html !" !!# $ (event)="fn(...)" React to events of a child component

Slide 29

Slide 29 text

Component Tree COMPONENTS AppComponent HTML Checkbox [checked] (changed) Parent Child

Slide 30

Slide 30 text

HANDS ON Your First Own Component

Slide 31

Slide 31 text

Generate Components ANGULAR CLI ng generate component path/component-name

Slide 32

Slide 32 text

A ToDo Component ANGULAR CLI ng generate component todo

Slide 33

Slide 33 text

COMPONENTS import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-todo', templateUrl: './todo.component.html', styleUrls: './todo.component.scss'] }) export class TodoComponent implments OnInit { // ... } Giving the todo a new home

Slide 34

Slide 34 text

Bind data COMPONENTS todo.component.ts todo.component.html import { Input, !!" } from '@angular/core'; @Component({ !# !!" !$ }) export class ToDoComponent { !% @Input() todo; } {{ todo.text }}

Slide 35

Slide 35 text

Usage COMPONENTS app.component.html !" !!# $ !&app-todo> [todo]="todo" Passing data to ToDoComponent

Slide 36

Slide 36 text

Create custom an event COMPONENTS todo.component.ts todo.component.html import { EventEmitter, Output ... } from '@angular/core'; @Component({ /* ... */ }) export class ToDoComponent { // ... @Output() update = new EventEmitter(); } {{ todo.text }}

Slide 37

Slide 37 text

Create custom an event COMPONENTS todo.component.ts todo.component.html @Component({ /* ... */ }) export class ToDoComponent { // ... @Output() update = new EventEmitter(); emitUpdate(todo) { this.update.emit(todo); } } {{ todo.text }}

Slide 38

Slide 38 text

Usage COMPONENTS app.component.html !" !!# $ !&app-todo> (update)=“show($event)" React to update of TodoComponent ☝ specified by

Slide 39

Slide 39 text

HANDS ON Handle Collections | *ngFor

Slide 40

Slide 40 text

Reuse with *ngFor COMPONENTS app.component.ts app.component.html @Component({ !" !!# !$ }) export class AppComponent { title = 'solid-foundations'; todos = [{ text: 'Prepare 2nd Workshop', isComplete: false }, { text: Hold 2nd Workshop', isComplete: false }]; !& !!# }

Slide 41

Slide 41 text

Recapitulation COMPONENTS is heavily used by Google Everything is a Component @Input lets data flow into a Component @Output creates custom events CLI automates your environment setup

Slide 42

Slide 42 text

co-IT.eu GmbH Inspire To Change @GregOnNet Thank you for listening speakerdeck.com/gregonnet/angular-basics-i

Slide 43

Slide 43 text

Sources CREDITS - ! Keynote AngularConnect 2018 by Igor Minar - Photos from Unsplash by - Dan Gold - Yoal Desurmont - angular.io