0.0.3 • Published 4 years ago

ng-glucose v0.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

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

LifecycleInterfaceMethodng-glucose decorator
On ChangesOnChangesngOnChanges@NgOnChanges
On InitOnInitngOnInit@NgOnInit
Do CheckDoCheckngDoCheck@NgDoCheck
After Content InitAfterContentInitngAfterContentInit@NgAfterContentInit
After Content CheckedAfterContentCheckedngAfterContentChecked@NgAfterContentChecked
After View InitAfterViewInitngAfterViewInit@NgAfterViewInit
After View CheckedAfterViewCheckedngAfterViewChecked@NgAfterViewChecked
On DestroyOnDestroyngOnDestroy@NgOnDestroy

License

MIT