Angular2 intro

22
Intro to Angular 2 @Sh_McK

Transcript of Angular2 intro

Page 1: Angular2 intro

Intro to Angular 2

@Sh_McK

Page 2: Angular2 intro

Angular 1.x

Now

Page 3: Angular2 intro

2009

Library for

Web DesignersFramework for

Web Developers

Page 4: Angular2 intro

1.3 -> 1.4 -> 1.5 -> 1.6 -> 2.0

Page 5: Angular2 intro

What do you think about ?

Page 6: Angular2 intro

Angular 2The Future

Page 7: Angular2 intro

Pop Quiz!What’s the difference between a

factory & Service?

In directives, when do you use the compile, link, or controller?

Page 8: Angular2 intro

Easier to ReasonFewer concepts

Simplified DI

One-way data flow

Tree structure

Automatic Change detection

Page 9: Angular2 intro

Easier to MaintainBetter stack traces

Improved testability

Style zones (Shadow DOM)

Page 10: Angular2 intro

Pop Quiz!

What advantages does React have over angular?

Page 11: Angular2 intro

Better PerformanceFaster

Memory Management

Lazy-loading

Server-side Rendering

Native Mobile Rendering

Service workers ?

Page 12: Angular2 intro

Quick ExampleTodoMVC with Firebase

Page 13: Angular2 intro

import {Component, View, bootstrap, NgFor, bind} from 'angular2/angular2';import {AngularFire, FirebaseArray} from 'firebase/angularfire';

@Component({selector: 'todo-app',appInjector: [AngularFire,bind(Firebase).toValue(new Firebase('https://webapi.firebaseio-demo.com/test'))

]})@View({

templateUrl: 'todo.html',directives: [NgFor]

})class TodoApp { … }

bootstrap(TodoApp);

Todo.TS / Todo.js

Page 14: Angular2 intro

class TodoApp {todoService: FirebaseArray;todoEdit: any;todoFilter: Boolean;

constructor(sync: AngularFire) {this.todoService = sync.asArray();this.todoEdit = null;this.todoFilter = null;

}enterTodo($event, newTodo) {

if($event.which === 13) { // ENTER_KEYvar todoText = newTodo.value.trim();if (todoText) {

this.addTodo(todoText);newTodo.value = '';

}}

}…

}

Todo.TS / Todo.js

Page 15: Angular2 intro

<h1>todos</h1><input

id="new-todo"placeholder="What needs to be done?"autofocus#newtodo(keyup)="enterTodo($event, newtodo)">

<li *ng-for="#todo of todoService.list">

<div class="view"[class.hidden]="(todoEdit == todo || todoFilter == todo.completed)">

<input class="toggle" type="checkbox"(click)="completeMe(todo)"[checked]="todo.completed">

<label (dblclick)="editTodo($event, todo)">{{todo.title}}</label><button class="destroy" (click)="deleteMe(todo)"></button>

</div> </li>

Todo.html

Page 16: Angular2 intro

What to Study?Because the web isn’t waiting for you.

Page 17: Angular2 intro

ES6 / TypeScriptImport / Export

Class

Template syntax

Page 18: Angular2 intro

Web Components<Template>

Shadow DOM

Page 19: Angular2 intro

Module LoaderWebpack

JSPM + System.js

Meteor

Page 20: Angular2 intro

Online Study Groupwww.tryangular2.com

Page 21: Angular2 intro

ResourcesWebpack-Starter

ES6-Starter

Plunker

Why Will Angular 2 Rock?

Twitter: @Sh_McK Kakao: Shawnmckay

Page 22: Angular2 intro

What do you think about ?