1

is it possible to get the value of e.g. changeDetection attribute defined as part of a given component's decoration?

import { Component, ChangeDetectionStrategy } from '@angular/core';

@Component({
  selector: 'app-banner',
  template: '<h1>{{title}}</h1>',
  changeDetection: ChangeDetectionStrategy.OnPush
})

export class BannerComponent { }

i've tried:

Reflect.getMetadataKeys(BannerComponent) // []
Reflect.getOwnMetadataKeys(BannerComponent) // []
Reflect.getMetadata('annotations', BannerComponent) // undefined

https://plnkr.co/edit/VXfcZH9BWPWbdyBOJRTV?p=preview

Ruslan
  • 9,927
  • 15
  • 55
  • 89

1 Answers1

0

Seemingly hacky but nevertherless a solution:

BannerComponent['__annotations__'][0]

https://plnkr.co/edit/HAbomBljAACHVz6N33m5?p=preview

Credits this SO answer.

Ruslan
  • 9,927
  • 15
  • 55
  • 89