I follow e.g. Angular Handbook and define
export function LogClass(constructor: Function) {
console.error('LogClass decorator executed for the constructor:');
console.log(constructor);
}
and on my class
@Component({
selector: ...
templateUrl: ...
})
@LogClass
export class MyCardComponent implements OnInit, OnDestroy {
...
But somehow I never see any kind of console output. This should also work according the Typescript manual. Anything I miss for using an own decorator?
UPDATE:
After trying around I think the sample is not a valid one. I guess that the statements are called just once and are not called every time the class is created as new instance - which is the main target I want to achieve!
Try to put your LogClass decorator below.
You can refer to this example
https://stackblitz.com/edit/angular-decorators-example-2?file=src%2Fapp%2Fapp.component.ts