4
鑑於下面的腳本,可以在angular 2 official tutorial中找到,「@」字符表示什麼?它是一個ecmascript 6功能嗎?ecmascript 6中的「@」char是什麼意思?
任何人都可以詳細說明嗎?
import {Component} from 'angular2/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 {
public title = 'Tour of Heroes';
public hero: Hero = {
id: 1,
name: 'Windstorm'
};
}
@用於指示裝飾和anotation之前有提名 –
參見HTTP://blog.thoughtram .io/angular/2015/05/03/the-difference-between-annotations-and-decorators.html和http://stackoverflow.com/questions/29775830/how-to-implement-a-typescript-decorator –