ngx-lifecycle
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

ngx-lifecycle

This library provides output directives for Angular 9+ lifecycle hooks. They can be applied to components and template elements in the following way:

<my-component
  (ngxInit)="log('init')"
  (ngxDestroy)="log('destroy')"
  (ngxChanges)="log('changes', $event)"
  (ngxViewInit)="log('view Init')"
  (ngxViewChecked)="log('view checked')"
  (ngxContentInit)="log('content init')"
  (ngxContentChecked)="log('content checked')"
  (ngxDoCheck)="log('do check')"
>
</my-component>

Usage

Import the NgxLifecycleModule into your application and apply directives to any component or template element as per above.

To listen to ngOnChanges, you need to add an output using both the decorator EmitChanges. This will create an EventEmitter for the respective component or directive.

import { EmitChanges } from 'ngx-lifecycle';

// property can have any name
@Output() @EmitChanges ngxChanges: EventEmitter<SimpleChanges>;

Package Sidebar

Install

npm i ngx-lifecycle

Weekly Downloads

0

Version

1.2.2

License

MIT

Unpacked Size

78.1 kB

Total Files

30

Last publish

Collaborators

  • sebastian-post96