KEMBAR78
What’s new in angular 2 - From FrontEnd IL Meetup | PPTX
© 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
Angular 1.x
Angular 2.0 building blocks
Components
Data binding
DI
Getting ready tips
Agenda
My first reaction…
Angular 1.x
Based on ES5
Based on jqLite (subset of jQuery)
Low performance
Why break something that works?
New standards
Performance
Consultants needs to make a living
Angular 1.x pains
$scope
Heavy data binding mechanism
It is all directives
Angular 2.0
ES 6
Components
New databinding
New DI
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
import {Component, View, bootstrap} from 'angular2/angular2';
// Annotation section
Component({
selector: 'my-app'
})
View({
template: '<h1>Hello {{ name }}</h1>'
})
// Component controller
class MyAppComponent {
name: string;
constructor() {
this.name = 'Alice';
}
}
bootstrap(MyAppComponent);
Meet the component
“controller”
view
<my-app></my-app>
Use the component
Angular 2.0 bootstrapping
Create a component
Create a template
Bootstrap your component
Use transpiler
Angular 1.x bootstrapping
Create module
Create a controller
Create HTML template
Register your controller in a module
Bootstrap your module in your application
Demo
Component
DI
Using ES6 / typescript
import
No need for double DI
Need to load the JS code
The component needs to
be
injected to the module
Import the directive
Use 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
Data Binding
No two way binding
[attribute]
(events)
#local variables
No ng-x are needed
Demo
Data Binding
Change Detection
Based on Object.observe
Organized as tree
Enahanced performance for immutable objects
Change Detection
1.x 2.0
How to get ready?
There are no migration paths (yet)
Be as modular a possible
Use controllerAs syntax and reduce the use of $scope
Componentize your app
AngularJs 1.x will continue to evolve so no rush…
Resources
http://angular.io
Change detection By Victor Savkin
https://www.youtube.com/watch?v=jvKGQSFQf10
My blog: http://blogs.Microsoft.co.il/ranw
Angular 2.0 is completely different
It is based on standards that aren’t ready
It can be used now for tests
No release date yet

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