在英雄之旅教程的app.component.ts
代码如下所示:Angular2如何知道哪个组件对应于模板?
import { Component } from '@angular/core';
export class Hero {
id: number;
name: string;
}
@Component({
selector: 'my-app',
template: `
<h1>{{title}}</h1>
<h2>{{hero.name}} details!</h2>
<div><label>id: </label>{{hero.id}}</div>
<div>
<label>name: </label>
<input [(ngModel)]="hero.name" placeholder="name">
</div>
`
})
export class AppComponent {
title = 'Tour of Heros';
hero: Hero = {
id: 1,
name: 'Windstorm'
};
}
不Angular2假设@component
声明之后而来的类是负责创建用于填充模板数据的类?