52
DIVE INTO ANGULAR, PART 4: ANGULAR 2.0 _by Oleksii Prohonnyi

Dive into Angular, part 4: Angular 2.0

Embed Size (px)

Citation preview

Page 1: Dive into Angular, part 4: Angular 2.0

DIVE INTO ANGULAR,PART 4: ANGULAR 2.0

_by Oleksii Prohonnyi

Page 2: Dive into Angular, part 4: Angular 2.0

AGENDA What’s new Build Angular 2 app in 6 steps ES6 vs TypeScript Architecture Module Component Template Data binding Service 1.x vs 2.0 comparison References

Page 3: Dive into Angular, part 4: Angular 2.0

WHAT’S NEW

Page 4: Dive into Angular, part 4: Angular 2.0

WHAT’S NEW Component-based Simplified directives Dependency injection TypeScript (ES6 + Types + Annotations) Generics Lambdas with TypeScript Forms and Validations

See more: dzone.com

Page 5: Dive into Angular, part 4: Angular 2.0

BUILD ANGULAR 2 APPIN 6 STEPS

Page 6: Dive into Angular, part 4: Angular 2.0

BUILD ANGULAR 2 APP0. Install Node.js and npm.1. Create and configure the project. 2. Create your application.3. Create a component and add it to your application.4. Start up your application.5. Define the web page that hosts the application.6. Build and run the application.

Download example: github.com See more: angular.io

Page 7: Dive into Angular, part 4: Angular 2.0

ES6 VS TYPESCRIPT

Page 8: Dive into Angular, part 4: Angular 2.0

ES6 VS TYPESCRIPT

Page 9: Dive into Angular, part 4: Angular 2.0

ES6 VS TYPESCRIPTSee more: EcmaScript 6/2015 TypeScript

Page 10: Dive into Angular, part 4: Angular 2.0

ARCHITECTURE

Page 11: Dive into Angular, part 4: Angular 2.0

ARCHITECTURE The framework consists of several cooperating libraries, some of

them core and some optional. The eight main building blocks of an Angular 2 application:

– Modules– Components– Templates– Metadata– Data binding– Directives– Services– Dependency injection

See more: angular.io

Page 12: Dive into Angular, part 4: Angular 2.0

ARCHITECTURE

Page 13: Dive into Angular, part 4: Angular 2.0

MODULE

Page 14: Dive into Angular, part 4: Angular 2.0

MODULE Every Angular app has at least one module, the root module,

conventionally named AppModule. An Angular module, whether a root or feature, is a class with an

@NgModule decorator. NgModule is a decorator function that takes a single metadata

object whose properties describe the module (declarations, exports, imports, providers, bootstrap).

Page 15: Dive into Angular, part 4: Angular 2.0

MODULE

Page 16: Dive into Angular, part 4: Angular 2.0

COMPONENT

Page 17: Dive into Angular, part 4: Angular 2.0

COMPONENT A component controls a patch of screen real estate that we could

call a view. We define a component's application logic — what it does to

support the view — inside a class. The class interacts with the view through an API of properties

and methods.

Page 18: Dive into Angular, part 4: Angular 2.0

COMPONENT

Page 19: Dive into Angular, part 4: Angular 2.0

COMPONENT In TypeScript, we attach metadata by using a decorator:

Page 20: Dive into Angular, part 4: Angular 2.0

TEMPLATE

Page 21: Dive into Angular, part 4: Angular 2.0

TEMPLATE We define a component's view with its companion template. A template is a form of HTML that tells Angular how to render the

component.

Page 22: Dive into Angular, part 4: Angular 2.0

DATA BINDING

Page 23: Dive into Angular, part 4: Angular 2.0

DATA BINDING Angular supports data binding, a mechanism for coordinating

parts of a template with parts of a component. There are four forms of data binding syntax. Each form has a

direction — to the DOM, from the DOM, or in both directions:

Page 24: Dive into Angular, part 4: Angular 2.0

DATA BINDING Two-way data binding is an important fourth form that combines

property and event binding in a single notation, using the ngModel directive.

Page 25: Dive into Angular, part 4: Angular 2.0

SERVICE

Page 26: Dive into Angular, part 4: Angular 2.0

SERVICE Service is a broad category encompassing any value, function,

or feature that our application needs. Almost anything can be a service. A service is typically a class

with a narrow, well-defined purpose. It should do something specific and do it well.

Page 27: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0 COMPARISON

Page 28: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0: Data binding

Page 29: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0: Filters

Page 30: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0: Local variables

Page 31: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0: Ng-App

Page 32: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0: Ng-Class

Page 33: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0: Ng-Click

Page 34: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0: Ng-Controller

Page 35: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0: Ng-Href

Page 36: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0: Ng-If

Page 37: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0: Ng-Model

Page 38: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0: Ng-Repeat

Page 39: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0: Ng-Show

Page 40: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0: Ng-Src

Page 41: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0: Ng-Style

Page 42: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0: Ng-Switch

Page 43: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0: Controllers

Page 44: Dive into Angular, part 4: Angular 2.0

1.X VS 2.0: Dependency injection

Page 45: Dive into Angular, part 4: Angular 2.0

SEE MORE

Page 47: Dive into Angular, part 4: Angular 2.0

REFERENCES

Page 49: Dive into Angular, part 4: Angular 2.0
Page 50: Dive into Angular, part 4: Angular 2.0

HOME TASK

Page 51: Dive into Angular, part 4: Angular 2.0

HOME TASK Main idea: migrate existing application on a new version of

Angular.js framework. Technical details:

– Component structure– Component router– TypeScript/EcmaScript 6– Readme with installation instructions

Page 52: Dive into Angular, part 4: Angular 2.0

Oleksii Prohonnyi

facebook.com/oprohonnyi

linkedin.com/in/oprohonnyi