import{Component}from'@angular/core';@Component({ selector:'my-app',template`<h1>Hello {{name}}</h1>`})exportclassAppComponent name ='Angular'}
在Plunker(注:一个在线编写、测试的平台)尝试这个QuickStart的例子QuickStart example on Plunker,不需要安装任何东西。也可以使用QuickStart seed(github上的一套用于学习的Demo代码,完成它的配置即搭建了一套本地的AngularJS的开发环境)在本地去尝试它,这样同时为真正的Angular应用程序的开发做了准备。
Angular applications are made up ofcomponents. Acomponentis the combination of an HTML template and a component class that controls a portion of the screen. Here is an example of a component that displays a simple string:
app/app.component.ts
Every component begins with andecoratorfunctionthattakes ametadataobject. The metadata objectdescribes how the HTML template and component class work together.
Theselectorproperty tells Angular to display the component inside a custom<my-app>tag in theindex.html.