Skahrz Skahrz - 1 year ago 111
TypeScript Question

DIsplay angular 2 decorator metadata in the browser

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.

For example, I need to access the metadata provided by the NgModule annotation :

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 ?

Answer Source

Use reflect-metadata.

npm install --save reflect-metadata

Then import it, and use it

import 'reflect-metadata'

let metadata = Reflect.getMetadata('annotations', AppModule)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download