Top Banner
© Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com What’s new in angular 2.0 Ran Wahle
22

What’s new in angular 2 - From FrontEnd IL Meetup

Aug 10, 2015

Download

Software

Ran Wahle
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: What’s new in angular 2 - From FrontEnd IL Meetup

© Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com

What’s new in angular 2.0

Ran Wahle

Page 2: What’s new in angular 2 - From FrontEnd IL Meetup

Angular 1.x Angular 2.0 building blocksComponentsData bindingDIGetting ready tips

Agenda

Page 3: What’s new in angular 2 - From FrontEnd IL Meetup

My first reaction…

Page 4: What’s new in angular 2 - From FrontEnd IL Meetup

Angular 1.x

Based on ES5Based on jqLite (subset of jQuery)Low performance

Page 5: What’s new in angular 2 - From FrontEnd IL Meetup

Why break something that works?

New standardsPerformanceConsultants needs to make a living

Page 6: What’s new in angular 2 - From FrontEnd IL Meetup

Angular 1.x pains

$scopeHeavy data binding mechanismIt is all directives

Page 7: What’s new in angular 2 - From FrontEnd IL Meetup

Angular 2.0

ES 6ComponentsNew databindingNew DI

Page 8: What’s new in angular 2 - From FrontEnd IL Meetup

Components

AngularJs 2.0 is built upon HTML5 WebComponents Each component is a javascript class (function in es5)It has a selector, view and a

Page 9: What’s new in angular 2 - From FrontEnd IL Meetup

import {Component, View, bootstrap} from 'angular2/angular2';

// Annotation sectionComponent({ selector: 'my-app'})View({ template: '<h1>Hello {{ name }}</h1>'})// Component controllerclass MyAppComponent { name: string;

constructor() { this.name = 'Alice'; }}

bootstrap(MyAppComponent);

Meet the componentDependency

injection

“controller”

view

Page 10: What’s new in angular 2 - From FrontEnd IL Meetup

<my-app></my-app>

Use the component

Page 11: What’s new in angular 2 - From FrontEnd IL Meetup

Angular 2.0 bootstrapping

Create a componentCreate a template Bootstrap your componentUse transpiler

Page 12: What’s new in angular 2 - From FrontEnd IL Meetup

Angular 1.x bootstrapping

Create moduleCreate a controller Create HTML templateRegister your controller in a moduleBootstrap your module in your application

Page 13: What’s new in angular 2 - From FrontEnd IL Meetup

Demo

Component

Page 14: What’s new in angular 2 - From FrontEnd IL Meetup

DI

Using ES6 / typescript importNo need for double DI

Need to load the JS codeThe component needs to be injected to the module

Page 15: What’s new in angular 2 - From FrontEnd IL Meetup

Import the directiveUse directive inside the view

import {Component, View, bootstrap, For} from 'angular2/angular2‘ or another external module;

template: `<ul> <li *ng-for="#name of names"> {{ name }} </li> </ul>`, directives: [NgFor]}

Import and directives

Page 16: What’s new in angular 2 - From FrontEnd IL Meetup

Data Binding

No two way binding[attribute](events)#local variables

No ng-x are needed

Page 17: What’s new in angular 2 - From FrontEnd IL Meetup

Demo

Data Binding

Page 19: What’s new in angular 2 - From FrontEnd IL Meetup

Change Detection1.x 2.0

Page 20: What’s new in angular 2 - From FrontEnd IL Meetup

How to get ready?

There are no migration paths (yet)Be as modular a possibleUse controllerAs syntax and reduce the use of $scopeComponentize your app

AngularJs 1.x will continue to evolve so no rush…

Page 21: What’s new in angular 2 - From FrontEnd IL Meetup

Resources

http://angular.ioChange detection By Victor Savkinhttps://www.youtube.com/watch?v=jvKGQSFQf10My blog: http://blogs.Microsoft.co.il/ranw

Page 22: What’s new in angular 2 - From FrontEnd IL Meetup

Angular 2.0 is completely differentIt is based on standards that aren’t readyIt can be used now for tests No release date yet