0.3.0 • Published 7 years ago

babel-plugin-annotate-ng v0.3.0

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

babel-plugin-annotate-ng

Build Status Coverage Status Package Dependency Package DevDependency

Annotate angular v1 DI dependency.

Usage

Add comment above export:

/* @ngInject */
export default class MonitorController {
  constructor($q, $sce, $animate) {
    this.$q = $q;
    this.$sce = $sce;
    this.$animate = $animate;
  }

  ngOnInit() {
  }

  ngAfterViewInit() {}

  ngOnDestroy() {}
}

/* @ngInject */
export function ShowcaseController($q, $sce, $animate) {
  this.$q = $q;
  this.$sce = $sce;
  this.$animate = $animate;

  // lifecycle method
  this.ngOnInit = ngOnInit;
  this.ngAfterViewInit = ngAfterViewInit;
  this.ngOnDestroy = ngOnDestroy;

  // function declare
  function ngOnInit() {}

  function ngAfterViewInit() {}

  function ngOnDestroy() {}
}

Add comment inline before declaration:

export default /* @ngInject */ class MonitorInlineController {
  constructor($q, $sce, $animate) {
    this.$q = $q;
    this.$sce = $sce;
    this.$animate = $animate;
  }

  ngOnInit() {
  }

  ngAfterViewInit() {}

  ngOnDestroy() {}
}

export /* @ngInject */ function ShowcaseInlineController($q, $sce, $animate) {
  this.$q = $q;
  this.$sce = $sce;
  this.$animate = $animate;

  // lifecycle method
  this.ngOnInit = ngOnInit;
  this.ngAfterViewInit = ngAfterViewInit;
  this.ngOnDestroy = ngOnDestroy;

  // function declare
  function ngOnInit() {}

  function ngAfterViewInit() {}

  function ngOnDestroy() {}
}

Add babel plugin:

{
  "plugin": ["annotate-ng"]
}

License

MIT