ng-glucose
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

NgGlucose

Angular lifecycle hooks as decorators. Compatible with Angular 9+.

Usage

import { Directive, ElementRef } from "@angular/core";
import { NgOnInit } from "ng-glucose";
 
@Directive({
  selector: "[appColor]",
})
export class ColourDirective {
  constructor(private el: ElementRef) {}
 
  @NgOnInit()
  private _setBackgroundColour(): void {
    this.el.nativeElement.style.backgroundColor = "black";
  }
 
  @NgOnInit()
  private _setFontColour(): void {
    this.el.nativeElement.style.color = "white";
  }
}

Angular Lifecycle Decorators

Lifecycle Interface Method ng-glucose decorator
On Changes OnChanges ngOnChanges @NgOnChanges
On Init OnInit ngOnInit @NgOnInit
Do Check DoCheck ngDoCheck @NgDoCheck
After Content Init AfterContentInit ngAfterContentInit @NgAfterContentInit
After Content Checked AfterContentChecked ngAfterContentChecked @NgAfterContentChecked
After View Init AfterViewInit ngAfterViewInit @NgAfterViewInit
After View Checked AfterViewChecked ngAfterViewChecked @NgAfterViewChecked
On Destroy OnDestroy ngOnDestroy @NgOnDestroy

License

MIT

Package Sidebar

Install

npm i ng-glucose

Weekly Downloads

2

Version

0.0.3

License

MIT

Unpacked Size

54.9 kB

Total Files

20

Last publish

Collaborators

  • aleksanderbodurri