在这个例子中,来自官方 Angular 2 文档,装饰器看起来像这样:
@Component({
selector: 'my-app',
template: '<h1>My First Angular App</h1>'
})
示例:不希望我的 HTML 代码中到处都是非标准元素,并且更喜欢类似的东西(注意:ng-angular
只是我想看到的一个例子):
import { Component } from '@angular/core';
@Component({
template: '<h1>Wait! Bloody wait some more.</h1>'
})
export class ListComponent { }
并使用了这样的东西:
<div ng-component="List"</div>
或者只有当你想创建一个新的 HTML 元素,然后在我上面的例子中坚持一个普通Listcontroller
的元素时,才使用这样的 Component 装饰器div
?