文件app.component.ts實施例中:https://angular.io/resources/live-examples/toh-1/ts/plnkr.html是如下:AngularJs 2中的AppComponent和@Component之間的連接是什麼?
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 Heroes';
hero: Hero = {
id: 1,
name: 'Windstorm'
};
}
現在,我們在AppComponent設定的title
值,它是在@Component的模板示出。那麼,想知道它有多可能?