2016
2016
2
var variableName: variableType = value; let variableName2: variableType = value; const variableName3: variableType = value;
let isDone: boolean = false;
const height: number = 6;
let name: string = 'Carl';
let names: string[] = ['Carl', 'Laurent'];
let notSure: any = 4;
class Person { constructor() {} speak:String() {return 'Yay';} }
class Child extends Person { constructor() {super();} speak:String() {return 'Nay';} } let person = new Child();
}
app.directive('MyDirective', function(){
return {
restrict: 'AE',
require: '?^^ngModel',
scope: { variable: '@' },
controller: function(...) {},
link: function(...) { ... }
}
});2
2
app.directive('MyDirective', function(){
return {
restrict: 'AE',
require: '?^^ngModel',
scope: { variable: '@' },
controller: function(...) {},
link: function(...) { ... }
}
});2
import { Component, Input} from '@angular/core'
@Component({
selector: 'my-component',
templateUrl: 'myComponent.html' }) export class MyComponent { @Input() variable:string; }
//provider, factory, constant and value
app.service('Service', function(){
var vm = this;
vm.myMethod = function(){
}
});
@Injectable()
export class Service {
myMethod(){}
}
2
2
Server side rendering of an Angular app
Great for SEO
Faster first page display
2
Reactive Functional Programming
<input type="text" [ngFormControl]="term"/>
this.items = this.term.valueChanges
.debounce(400)
.map(term => term.trim()) .distinctUntilChanged() .subscribe(term => this.wk.search(term));
2
Reactive Functional Programming
getDataFromNetwork()
.debounce(300)
.filter (rep1 => rep1 != null)
.flatMap(rep1 => getDateFromAnotherRequest(rep1))
.map(rep2 => `${rep2} transformed`)
.subscribe(value => console.log(`next => ${value}`))
Events, HTTP calls are observables!
2
2
https://angular.io/docs/ts/latest/guide/upgrade.html
Thanks!
http://tinyurl.com/zenika27102016