SlideShare a Scribd company logo
Angular 2 preview
Agenda
AngularJS recap
Motivation
Components
New templates
Unstable things
Q&A
2
Consultant
&
Trainer
at Info Support
Cloud, BI, Web, Mobile
C#, JavaScript, SQL
Early adopter, musician
Yoeri Van Damme
yoeri.vandamme@infosupport.com
@YoeriVD
3
5
DO NOT USE IT
Angular2v2
Angular2v2
Angular2v2
Angular2v2
Angular2v2
12
Demo: angular 1.x
Steps to build NG1 app
1. Create module
2. Declare ng-app
3. Add controller
4. Inject $scope and add items
5. Declare controller
6. Create template
14
Angular 1.x
15
module
$scope
views $filter
$controller
DDO Directive
Provider Factory
Service
Constant
Valueconfig
run
16
17
Steps to build NG2 app
1. Create component
2. Create Template
3. Bootstrap
4. Transpile
18
Steps to build NG2 app
1. Create component
2. Create Template
3. Bootstrap
4. Transpile
19
Angular 2.0
20
module
$scope
views $filter
$controller
DDO Directive
Provider Factory
Service
Injectables
Constant
Valueconfig
run
Angular 2.0
21
Component
Template
Template
Component
Template
Component
Component
Template
Component
Template
Component
Component Ccomponent
Motivation
Enable html development, not change it
Embrace standards, not define
Angular 1.x will be obsolete
Simplify
Improve
– Performance
– Learning curve
22
COMPONENTS
23
Components
1 of 2 kinds of directives:
– ComponentDirective
– DecoratorDirective
24
Component
Built on TypeScript
Marked by annotations
– @Component
– @View
Nested
Unidirectional Tree
 no more $apply()!
25
Annotations
Metadata for component
– @View
– @Component
– @Directive
– @Parent
– …
26
TYPESCRIPT
27
Why TypeScript?
= ES6 today
– Transpile with Traceur
– Compile to ES5
Replace AtScript
STATIC TYPES!
28
Tooling
Intellisense!
(autocompletion)
29
Demo: bootstrap an app
TEMPLATES
31
Templates – Angular 1.x
Type of value depends on implementation
Need for work-arounds
– ng-src, ng-max, ng-min, ng-href,…
32
<h1>Slides</h1>
<div ng-repeat="slide in slides" class="slidePreview">
<a ng-click="openSlide($index)">
<img ng-src="{{ slide }}" class="previewImage" />
</a>
</div>
Templates Angular 2.0
Defined syntax
Readable by tools and humans
Set properties instead of attributes
33
<h1>Slides</h1>
<div *for="#slide of slides" class="slidePreview">
<a (click)="openSlide($index)">
<img [src]="slide" class="previewImage" />
</a>
</div>
Templates – data-binding
Set properties, not attributes
<li [hidden]="recipe.isHidden">
vs
<li ng-hide="recipe.isHidden">
# of properties > # of attributes
[] for properties
myItem[‘myProp’] = something;
Right side = expression (always)
34
Result
A lot of directive are not needed anymore:
– ng-bind ng-bind-html ng-bind-template
ng-class ng-class-even ng-class-odd
ng-style ng-disabled ng-readonly
ng-selected ng-show ng-hide ng-src
ng-srcset ng-href ng-value
35
Angular 1 - Expression vs statement
<my-component select="user.name(current)" />
What is select?
– Value assignment?
– Property assignment (with side effects?)?
– Event (function expression) ?
Tools can’t tell, humans can’t tell.
36
Angular 2 - Expression vs statement
<my-component [select]="user.name(current)" />
<my-component (select)="user.name(current)" />
37
expression
statement
Angular 2 - Expression vs statement
Expressions
[prop]=“value”
Driven by change detection
No side-effects
Null suppression
1 ‘;’
Statements
(event)=“handler”
Driven by event
All about side effects
Error on null
n ‘;’
38
Result
A lot of other directives are not needed
anymore:
– ng-blur ng-change ng-checked ng-copy
ng-cut ng-paste ng-click ng-dblclick
ng-open ng-submit ng-keydown
ng-keypress ng-keyup ng-mousedown
ng-mouseleave ng-mouseenter
ng-mousemove ng-mouseover ng-mouseup
39
Did anyone count all those
directives?
The claims-based identity model 40
41
Demo: creating a template
Templates
String interpolation
– Syntax same, but works differently
43
Why all the trouble for
components?!
44
WebComponents is ‘native’!
Enable html development, not change it
Embrace standards, not define
Only supported in Chrome
Mocked in other browsers
45
Structure of a Webcomponent
Visible DOM
Implicit DOM
– video control
– Every input
– …
Custom events
46
Demo: shadow DOM
Angular 2 Views
Compile only once
Elements never passed directly to component
controller
Cacheable => webcomponents
48
THINGS WAY TOO UNSTABLE TO
DEMO
49
Directive
50
import {Directive} from 'annotations';
import {NgElement} from 'angular2/angular2';
@Directive({
selector: '[alert]',
bind: {
}
})
export class Alert {
text: string;
constructor(private el : NgElement) {
el.domElement.style.color = "red";
}
}
Forms
The claims-based identity model 51
Dependency Injection
Mature model
Now with control of lifetime
Childcontainer
Binding dependencies
…
52
New router
~ same as Angular 1.4+
Built by Rob Eisenberg
– Durandal
– Auralia
53
So what do we know?
Angular2 is all about components
Based on near-future standards
– ES6 (TypeScript)
– WebComponents
Much much more simple
54
Questions?
github.com/YoeriVD
@YoeriVD
linkedin.com/in/YoeriVD
55

More Related Content

What's hot (20)

PDF
Angular2 with TypeScript
Rohit Bishnoi
 
PDF
Angular 2... so can I use it now??
Laurent Duveau
 
PPTX
Introduction to Angular2
Ivan Matiishyn
 
PDF
Angular 2 - The Next Framework
Commit University
 
PPTX
Code migration from Angular 1.x to Angular 2.0
Ran Wahle
 
PDF
Introduction to Angular 2
Naveen Pete
 
PDF
Adventures with Angular 2
Dragos Ionita
 
PDF
Tools & tricks for testing React applications
React London Community
 
PPTX
Green Custard Friday Talk 21: React Hooks
Green Custard
 
PPTX
Clean Test
Noam Almog
 
PPT
Google Web Toolkit
Christos Stathis
 
PPTX
Controllers in AngularJs
K Arunkumar
 
PPTX
Dive into Angular, part 4: Angular 2.0
Oleksii Prohonnyi
 
PDF
View controller life cycle
SV.CO
 
ODP
Introduction to Angular 2
Knoldus Inc.
 
PDF
هیبرید کارا، از رویا تا واقعیت!
Web Standards School
 
PDF
Angular the Good Parts
Krzysztof Kula
 
PDF
PWA night vol.11 20191218
bitpart
 
DOCX
Understand components in Angular 2
codeandyou forums
 
Angular2 with TypeScript
Rohit Bishnoi
 
Angular 2... so can I use it now??
Laurent Duveau
 
Introduction to Angular2
Ivan Matiishyn
 
Angular 2 - The Next Framework
Commit University
 
Code migration from Angular 1.x to Angular 2.0
Ran Wahle
 
Introduction to Angular 2
Naveen Pete
 
Adventures with Angular 2
Dragos Ionita
 
Tools & tricks for testing React applications
React London Community
 
Green Custard Friday Talk 21: React Hooks
Green Custard
 
Clean Test
Noam Almog
 
Google Web Toolkit
Christos Stathis
 
Controllers in AngularJs
K Arunkumar
 
Dive into Angular, part 4: Angular 2.0
Oleksii Prohonnyi
 
View controller life cycle
SV.CO
 
Introduction to Angular 2
Knoldus Inc.
 
هیبرید کارا، از رویا تا واقعیت!
Web Standards School
 
Angular the Good Parts
Krzysztof Kula
 
PWA night vol.11 20191218
bitpart
 
Understand components in Angular 2
codeandyou forums
 

Similar to Angular2v2 (20)

PPTX
Сергей Больщиков "Angular Components: все уже за, а вы еще нет?"
Fwdays
 
PDF
Nicolas Embleton, Advanced Angular JS
JavaScript Meetup HCMC
 
PPTX
Angular Js Basics
أحمد عبد الوهاب
 
PPTX
Angularjs Basics
Anuradha Bandara
 
PDF
Angular 16 – the rise of Signals
Coding Academy
 
PPTX
Angular
sridhiya
 
PPTX
Grails & Angular: unleashing the dynamic duo
Rubén Mondéjar Andreu
 
PPTX
The tooling Api demystified, It is not only for developers, Doria Hamelryk & ...
CzechDreamin
 
PPTX
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
Binary Studio
 
ODP
Angular js-crash-course
Keith Bloomfield
 
PDF
Practical Dynamic Actions - Intro
Jorge Rimblas
 
PDF
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
George Nguyen
 
PPTX
Visual Testing: The Missing Piece of the Puzzle -- presentation by Gil Tayar
Applitools
 
PDF
Overcoming (organizational) scalability issues in your Prometheus ecosystem
QAware GmbH
 
PDF
Kogito: cloud native business automation
Mario Fusco
 
PDF
ANGULARJS.pdf
ArthyR3
 
PDF
From User Action to Framework Reaction
jbandi
 
PDF
GDayX - Advanced Angular.JS
Nicolas Embleton
 
PDF
Advanced Dagger talk from 360andev
Mike Nakhimovich
 
PDF
From User Action to Framework Reaction
Jonas Bandi
 
Сергей Больщиков "Angular Components: все уже за, а вы еще нет?"
Fwdays
 
Nicolas Embleton, Advanced Angular JS
JavaScript Meetup HCMC
 
Angular Js Basics
أحمد عبد الوهاب
 
Angularjs Basics
Anuradha Bandara
 
Angular 16 – the rise of Signals
Coding Academy
 
Angular
sridhiya
 
Grails & Angular: unleashing the dynamic duo
Rubén Mondéjar Andreu
 
The tooling Api demystified, It is not only for developers, Doria Hamelryk & ...
CzechDreamin
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
Binary Studio
 
Angular js-crash-course
Keith Bloomfield
 
Practical Dynamic Actions - Intro
Jorge Rimblas
 
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
George Nguyen
 
Visual Testing: The Missing Piece of the Puzzle -- presentation by Gil Tayar
Applitools
 
Overcoming (organizational) scalability issues in your Prometheus ecosystem
QAware GmbH
 
Kogito: cloud native business automation
Mario Fusco
 
ANGULARJS.pdf
ArthyR3
 
From User Action to Framework Reaction
jbandi
 
GDayX - Advanced Angular.JS
Nicolas Embleton
 
Advanced Dagger talk from 360andev
Mike Nakhimovich
 
From User Action to Framework Reaction
Jonas Bandi
 
Ad

Angular2v2

Editor's Notes

  • #14: Bootstrap + create controller
  • #25: Viewport: https://github.com/angular/angular/blob/master/modules/angular2/src/directives/if.js
  • #31: Bootstrap + create controller
  • #34: !foreach is ondertussen al compleet veranderd
  • #52: http://angularjs.blogspot.be/2015/03/forms-in-angular-2.html