babel-plugin-annotate-ng

0.3.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i babel-plugin-annotate-ng

Weekly Downloads

0

Version

0.3.0

License

ISC

Last publish

Collaborators

  • bornkiller