Suguru Inatomi @laco0416
ng-japan 2016
the Fact
"Angular" = Platform
Types as API documents
Spec: javascript-decorators
Status: tc39/ecma262
tsc --experimentalDecorators
var ProfileComponent = ng.core.Component({
selector: "app-profile",
template: "<p>Name: {{ name }}</p>"
}).Class({
constructor: function() {
this.name = "laco";
}
});
@Component({
selector: "app-profile",
template: "<p>Name: {{ name }}</p>"
})
class ProfileComponent {
name: string;
constructor() {
this.name = "laco";
}
}
import {Http} from "angular2/http";
@Injectable()
class MyService {
constructor(private anyNameForHttp: Http) {
}
}
Good-bye "$http"
Safe & Productive
"Why don't you use TypeScript?"
No new feature
Migration support
angular.module("myApp")
.component("myComponent", {...});
<my-component></my-component>
$routeConfig: [
{ path: '/a/b/c', component: 'myComponent' },
...
]
npm i -S angular@1.5.x @angular/router
ng-model
<input ng-model="myName">
<span>{{ myName }}</span>
Two-way Data-binding
[(ngModel)]
<input [(ngModel)]="myName">
<input [ngModel]="myName"
(ngModelChange)="myNameChanged($event)">
Sugar of One-way + Event handler
[()]
Angular generates VM friendly code
Don't worry number of $watch
!
Angular 2 for Node.js
"angular2/core"
Node.js / Java / PHP / .Net / Python / ...
ViewEncapsulation
@Component({
selector: "my-component",
encapsulation: ViewEncapsulation.Native
})
class MyComponent{}
Default: ViewEncapsulation.Emulated
Please ask me later!!
Dynamic Module Loader
systemjs/systemjs
Reactive Programming in JavaScript
ReactiveX/RxJS
Spec: es-observable
Status: tc39/ecma262
<input onkeyup="...">
element.animate(...).cancel()
connection.onmessage(e=>...)
xhr.abort()
Polyfill for Zones
Spec: Zones
Status: tc39/ecma262
beforeTask()
, afterTask()
, ...zone.fork({
onInvokeTask: (delegate, current, target, task, applyThis, applyArgs) => {
try {
console.log("before")
return delegate.invokeTask(target, task, applyThis, applyArgs);
} finally {
console.log("after");
}
}
}).run(() => {
setTimeout(() => { console.log("task"); }, 0);
});
Changes happens in ...:
setTimeout()
, setInterval()
click
, submit
Async tasks Changes
=> Angular watches all task
tsc --emitDecoratorMetadata
ng2 = ng1.add( XXX );
ngClick, ngKeydown, ngKeyup, ngBlur, ngMaxLength, ngMinLength, ngMouseOver, ngMouseLeave, ngBind, ngFocus, ...
.directive(), .controller(), .service(), .factory(), .constant(), .config(), ...
Properties: <input [value]="userName">
Events: <button (click)="send($event)">...</button>
Two-way: <input [(ngModel)]="userName">
Component: @Component
ng2 = ng1.add(XXX)
<my-directive
prop1="ctrl.someProp"
prop2="some text">
</my-directive>
Expression? Text?
<my-directive
[prop1]="someProp"
prop2="some text">
</my-directive>
Static Analyzable
Angular on the (Next) Web Standards
To Learn: Angular feature < Web Standards
Everyone has Something to Teach Others
Suguru Inatomi @laco0416
ng-japan 2016
http://goo.gl/TeM0Fr