创建 AppComponent 类的实例
当你通过 main.ts 中的 AppComponent 类启动时,Angular 在 index.html 中查找一个
装饰器
- 装饰器是用来标记的,标记为一个组件、服务……
- 接受元数据对象
@Component() @NgModule() @Injectable() @Input
管道
管道 是格式化字符串、金额、日期和其它显示数据的好办法。 Angular 发布了一些内置管道,而且你还可以创建自己的管道。
// async 管道<div class="shipping-item" *ngFor="let shipping of shippingCosts | async"><span>{{ shipping.type }}</span><span>{{ shipping.price | currency }}</span></div>
// 管道还能接收一些参数,来控制它该如何进行转换。<p>The date is {{today | date:'fullDate'}}</p>
元数据(metadata)
- 有些元数据位于
_@_[_Component_](https://angular.cn/api/core/Component)装饰器中,你会把它加到组件类上。 - 另一些关键性的元数据位于
_@NgModule_装饰器中。顶级类 AppModule
公共属性(public)
Angular 只会绑定到组件的公共属性。
这个 messageService 属性必须是公共属性,因为你将会在模板中绑定到它。export class MessagesComponents implements OnInit {constructor(public messageService: MessageService) {}}
