【发布时间】:2016-03-31 15:09:59
【问题描述】:
当我在 TypeScript 中使用元数据注释类时,例如要创建 Angular2 组件,我可以访问该类中的元数据吗?
import {Component} from 'angular2/core';
@Component({
selector: 'app',
templateUrl: '/app/components/app/app.component.html'
})
export class AppComponent {
// can I access 'templateUrl' from above annotation here?
}
【问题讨论】:
-
一般的答案是“视情况而定”,装饰器只是包装你的类的东西。它可以根据自己的选择公开或不公开属性。它没有必须让您访问它 - 事实上它可能会选择完全忽略传递给它的参数。
标签: typescript angular