ng-annotations
Extract metadata of Angular components, directives, service etc.
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