Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Angular Basics I

Angular Basics I

These slides introduce you to Angular.

The corresponding workshop was given at Angular Meetup Leipzig:
https://www.meetup.com/de-DE/Angular-Meetup-Leipzig/events/260114805/

Description (German)
---------------------------

Angular Ramp Up ist eine zweiteilige Workshop-Reihe, in der wesentliche Techniken über Angular vermittelt werden, um dich fit für das nächste Projekt zu machen.
Du lernst die wichtigen Elemente von Angular kennen und wendest sie direkt in deinem eigenen Testprojekt an.

Folgende Techniken werden wir gemeinsam erlernen und ausprobieren:

* Was ist Angular?
* Was ist TypeScript?
* Wieso ist Angular so beliebt?
* Was sind Components?
* Wie kommunizieren Components untereinander?
* Dependency Injection in Angular
* Wie nutze ich HTTP-Backends?
* Wie baue ich eine solide Navigation zwischen mehreren Views auf?

Rock On & Code 😎

Gregor Woiwode

April 09, 2019
Tweet

More Decks by Gregor Woiwode

Other Decks in Programming

Transcript

  1. Values N G U L A R Apps that users

    ♥ to use Apps that developers to build Community where everyone feels welcome
  2. 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
  3. N G U L A R Clientside Rendering Serverside Rendering

    Mobile Native Mobile Embedded Flavours
  4. 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
  5. Group wisely N G U L A R T o

    g g le All Prepare Workshop Hold the Workshop ToDo App List Item
  6. Think in features N G U L A R T

    o g g le All Prepare Workshop Hold the Workshop ToDo App Header ToDos
  7. Purpose C O M P O N E N T

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

    S Representation
  9. 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'; }
  10. 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'; }
  11. 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'; }
  12. 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'; }
  13. 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'; }
  14. 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'; }
  15. Assign data COMPONENTS app.component.ts app.component.html @Component({ !" !!# }) export

    class AppComponent { title = 'solid-foundations'; todo = { text: 'Prepare 1st Workshop', isComplete: true }; } <!-- ... --> <label> <input type="checkbox“ [checked]="todo.isComplete" /> {{ todo.text }} </label>
  16. Handle events COMPONENTS app.component.ts app.component.html @Component({ !" !!# }) export

    class AppComponent { !" !!# show(todo) { alert(todo); } } <!-- ... --> <label> <input type="checkbox" [checked]="todo.isComplete" (change)=“show(todo)" /> {{ todo.text }} </label>
  17. Input Bindings COMPONENTS app.component.html <!-- ... --> <label> <input type="checkbox"

    [checked]="todo.isComplete" (change)=“show(todo)" /> {{ todo.text }} </label> [property]="..." Let data flow into a child component
  18. Output Bindings COMPONENTS app.component.html !" !!# $ <label> <input type="checkbox"

    [checked]="todo.isComplete" (change)=“show(todo)" !% {{ todo.text }} !&label> (event)="fn(...)" React to events of a child component
  19. 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
  20. Bind data COMPONENTS todo.component.ts todo.component.html import { Input, !!" }

    from '@angular/core'; @Component({ !# !!" !$ }) export class ToDoComponent { !% <app-todo [todo]="value"> @Input() todo; } <!-- ... --> <label> <input type="checkbox" [checked]="todo.isComplete" /> {{ todo.text }} </label>
  21. 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(); } <!-- ... --> <label> <input type="checkbox" [checked]="todo.isComplete" (change)=“emitUpdate(todo)" /> {{ todo.text }} </label>
  22. 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); } } <!-- ... --> <label> <input type="checkbox" [checked]="todo.isComplete" (change)=“emitUpdate(todo)" /> {{ todo.text }} </label>
  23. Usage COMPONENTS app.component.html !" !!# $ <app-todo [todo]="todo" (update)="show($event)" >!&app-todo>

    (update)=“show($event)" React to update of TodoComponent ☝ specified by
  24. 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 }]; !& !!# } <!-- ... --> <app-todo [todo]="todo" (update)="show($event)“ *ngFor="let todo of todos" ></app-todo>
  25. 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
  26. co-IT.eu GmbH Inspire To Change @GregOnNet Thank you for listening

    speakerdeck.com/gregonnet/angular-basics-i
  27. Sources CREDITS - ! Keynote AngularConnect 2018 by Igor Minar

    - Photos from Unsplash by - Dan Gold - Yoal Desurmont - angular.io