#BzhCmp #Ng2BzhCmp
BreizhCamp 2015
#BzhCmp
BreizhCamp 2015
#BzhCmp
Full-Stack Web Developer
Co-Fondateur de @RennesJS
#Ng2BzhCmp #BzhCmp
BreizhCamp 2015
#BzhCmp
Architecte Web, passionné par le Front-End
Co-Fondateur de @RennesJS
#Ng2BzhCmp #BzhCmp
#Ng2BzhCmp #BzhCmp
Meetup le dernier jeudi de chaque mois
25/06/2015 à Epitech
#Ng2BzhCmp #BzhCmp
#Ng2BzhCmp #BzhCmp
Octobre 2014:
#Ng2BzhCmp #BzhCmp
Mars 2015
#Ng2BzhCmp #BzhCmp
Se baser sur les futurs standards du web
WebComponents
ES6 / ES7 / TypeScript*
EverGreen Browsers
#Ng2BzhCmp #BzhCmp
ES5
ES6
ES7
TS
#Ng2BzhCmp #BzhCmp
#Ng2BzhCmp #BzhCmp
import { Annotation } from 'angular2/angular2';
import { Api as ApiSpeakers } from './api/speakers';
@Annotation({
property: 'value'
})
class Talk {
speakers: Array<String>;
thread: String;
constructor(thread: String, api: ApiSpeakers) {
this.thread = thread;
api.get().then((speakers) => {
this.speakers = speakers;
});
}
}
TS
#Ng2BzhCmp #BzhCmp
#Ng2BzhCmp #BzhCmp
Version Alpha "Developer Preview"
Solution instable
API changeante
Documentation en cours
#Ng2BzhCmp #BzhCmp
BreizhCamp 2015
#Ng2BzhCmp #BzhCmp
Angular 1
Angular 2
BreizhCamp 2015
#BzhCmp
#Ng2BzhCmp #BzhCmp
Directives Angular 1.X
Directives Angular 2.X
Components Angular 2.X
Etendre le DOM
Encapsule un template
BreizhCamp 2015
#BzhCmp
#Ng2BzhCmp #BzhCmp
BreizhCamp 2015
#BzhCmp
#Ng2BzhCmp #BzhCmp
<!DOCTYPE html>
<html>
<head>
<title>Angular 2 - BreizhCamp</title>
<script src="//github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.90/traceur-runtime.js"></script>
<script src="//jspm.io/system@0.16.js"></script>
<script src="//code.angularjs.org/2.0.0-alpha.23/angular2.dev.js"></script>
</head>
<body>
<my-component></my-component>
<script type="module">
import { bootstrap } from 'angular2/angular2';
import { MyComponent } from 'app/my-component';
bootstrap(MyComponent);
</script>
</body>
</html>
HTML
BreizhCamp 2015
#BzhCmp
#Ng2BzhCmp #BzhCmp
<my-component></my-component>
import {
Component, View
} from 'angular2/angular2';
@Component({
selector: 'my-component'
})
@View({
template:
'<div>Hello, BreizhCamp</div>'
})
export class MyComponent {
}
HTML
TS
BreizhCamp 2015
#BzhCmp
#Ng2BzhCmp #BzhCmp
import {
Component, View
} from 'angular2/angular2';
@Component({
selector: 'my-component'
})
@View({
template:
'<div>Hello, {{message}}</div>'
})
export class MyComponent {
constructor() {
this.message = 'BreizhCamp';
}
}
<my-component></my-component>
HTML
TS
BreizhCamp 2015
#BzhCmp
#Ng2BzhCmp #BzhCmp
import {
Component, View
} from 'angular2/angular2';
@Component({
selector: 'my-component',
properties: {
message: 'msg'
}
})
@View({
template:
'<div>Hello, {{message}}</div>'
})
export class MyComponent {
}
<my-component msg="BreizhCamp">
</my-component>
HTML
TS
BreizhCamp 2015
#BzhCmp
#Ng2BzhCmp #BzhCmp
import {
Directive
} from 'angular2/angular2';
@Directive({
selector: '[tooltip]',
properties: {
text: 'tooltip'
},
hostListeners: {
mouseover: 'display()'
}
})
export class Tooltip {
display() {
console.log(this.text);
}
}
<div tooltip="Hello BreizhCamp">
Hover Me!
</div>
HTML
TS
BreizhCamp 2015
#BzhCmp
#Ng2BzhCmp #BzhCmp
import {
Component, View
} from 'angular2/angular2';
import { Tooltip } from './tooltip';
@Component({
selector: 'my-component',
properties: {
message: 'msg'
}
})
@View({
template:
'<div tooltip="Yo!">Hi, {{message}}</div>',
directives: [Tooltip]
})
export class MyComponent {}
<my-component msg="BreizhCamp">
</my-component>
HTML
TS
#Ng2BzhCmp #BzhCmp
<div>Hello, {{username}}</div>
<button [model]="message" (click)="hello(message)">
Click Me!!
</button>
<audio-player #player></audio-player>
<button (click)="player.pause()">Pause</button>
Interpolation
Property binding / Event binding
Local variable (référence)
#Ng2BzhCmp #BzhCmp
<div *if="user">Hello, {{user.name}}</div>
// Équivalent à
<template if="user">
<div>Hello, {{user.name}}</div>
</template>
<ul *if="list.length">
<li *for="#item of list">
{{item.title}}
</li>
</ul>
Whole template
BreizhCamp 2015
#BzhCmp
#Ng2BzhCmp #BzhCmp
import { MyService } from './my-service';
@Component({
selector: 'my-component',
injectables: [MyService]
})
@View({
templateUrl: '/path/to/my-component.html'
})
class MyComponent {
myService: MyService;
constructor(myService: MyService) {
this.myService = myService;
}
fetchData() {
this.myService.get().then((list) => {
console.log(list);
});
}
}
BreizhCamp 2015
#BzhCmp
#Ng2BzhCmp #BzhCmp
#Ng2BzhCmp #BzhCmp
#Ng2BzhCmp #BzhCmp
#Ng2BzhCmp #BzhCmp
BreizhCamp 2015
#BzhCmp
#Ng2BzhCmp #BzhCmp