在浏览器中显示角度2装饰器元数据 [英] DIsplay angular 2 decorator metadata in the browser
本文介绍了在浏览器中显示角度2装饰器元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习Angular 2的内部组件和行为,并且在尝试显示由不同装饰器提供的元数据时遇到了问题.
I m learning Angular 2 internal components and behaviours, and I m having a problem while trying to display the metadata provided by the different decorators.
例如,我需要访问NgModule批注提供的元数据:
For example, I need to access the metadata provided by the NgModule annotation :
@NgModule({
declarations: [
/* ... */
],
imports: [
/* ... */
],
providers: [
/* ... */
],
bootstrap: [/* ... */]
})
export class AppModule { }
console.log(new AppModule());
但是我找不到与该日志信息内的装饰器元数据有关的任何内容.您知道我可以从我的应用程序中获取这些信息吗?
But I can't find anything concerning the decorators metadata inside of that log information. Do you know where I can get these informations inside of my applications ?
推荐答案
使用 reflect-metadata
.
npm install --save reflect-metadata
然后将其导入并使用
import 'reflect-metadata'
let metadata = Reflect.getMetadata('annotations', AppModule)
这篇关于在浏览器中显示角度2装饰器元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文