DIsplay angular 2 decorator metadata in browser

I am learning Angular 2 internal components and behaviors, and I am having trouble trying to display the metadata provided by various decorators.

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 about decorator metadata inside this log information. Do you know where I can get this information inside my applications?

+4
source share
1 answer

Use reflect-metadata.

npm install --save reflect-metadata

Then import it and use it

import 'reflect-metadata'

let metadata = Reflect.getMetadata('annotations', AppModule)
+6
source

Source: https://habr.com/ru/post/1660901/


All Articles