@gund/ng-annotations

Extract metadata of Angular components, directives, service etc.

Stats

StarsIssuesVersionUpdatedCreatedSize
@gund/ng-annotations
3290.3.15 years ago5 years agoMinified + gzip package size for @gund/ng-annotations in KB

Readme

ng-annotations

Extract metadata of Angular components, directives, service etc.

Travis CI Coverage Npm Npm Downloads semantic-release

Installation

$ npm install --save @gund/ng-annotations

Usage

Import Annotations class first:

import { Annotations } from 'ng-annotations';

Then get annotations for you component:

@Component({selector: 'some-component'})
class MyComponent {
  constructor() {
    const annotations = Annotations.getFor(MyComponent);
    // annotations.selector here will be `some-component`
  }
}

Documentation

Annotations

class Annotations {
  static getFor(type: Type<any>): AllDecorators;
  static getForDirective(type: Type<any>): Directive;
  static getForComponent(type: Type<any>): Component;
  static getForPipe(type: Type<any>): Pipe;
}

See src/annotations.ts for full reference

Description: Class with static methods to get annotations from type.

getFor()

static getFor(type: Type<any>): AllDecorators;

Description: Get annotations for the type. It will return all annotations found. If you want more specific type use methods below.

getForDirective()

static getForDirective(type: Type<any>): Directive;

Description: Get annotations for directive. Calls getFor() but returns type specific for Directive.

getForComponent()

static getForComponent(type: Type<any>): Component;

Description: Get annotations for component. Calls getFor() but returns type specific for Component.

getForPipe()

static getForPipe(type: Type<any>): Pipe;

Description: Get annotations for pipe. Calls getFor() but returns type specific for Pipe.

Development

To generate all *.js, *.js.map, *.d.ts and *.metadata.json files:

$ npm run build

To lint all *.ts files:

$ npm run lint

To run unit tests:

$ npm test

License

MIT © Alex Malkevich

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.