Slide 20
Slide 20 text
ES6 Modules
Class
Decorator
Class property
import { Component, Injectable } from 'angular2/core';
@Injectable()
class Hero { id: number; name: string; }
@Component({
selector: 'my-app',
templateUrl: './my-app.html',
styleUrls: ['./my-app.css']
})
export class AppComponent {
public title = 'Tour of Heroes';
public heroes = HEROES;
public selectedHero: Hero;
onSelect(hero: Hero) {
this.selectedHero = hero;
}
getSelectedClass(hero: Hero) {
return {
selected: hero === this.selectedHero
};
}
}
var HEROES: Hero[] = [
{ "id": 11, "name": "Mr. Nice" }, // ...
];