angular-one-decorators
v1.0.3
Published
Typescript 2 decorators for angular 1 projects
Downloads
16
Maintainers
Readme
Typescript 2 Decorators for angular 1
Here you can find some useful decorators written in Typescript 2 for angular 1 project.
Goal of these decorators
To help you out with the new semantic of angular 2 components I wrote some simple decorators in Typescript
Examples
Below you will find useful examples of the different decorators
Service
export let moduleName = 'service.module'
@Service({
module: moduleName, // name of the angular module where you would like to attach this service,
serviceName: 'yourServiceName' // then name under which this service will be injected
})
export class YourNewService{
}
Component
export let moduleName = 'component.module';
@Component({
selector: 'httml-selector', // the name of your html-element
module: moduleName , //name of the angular module where you would like to attach this component ,
template: require('./your.template.html') // the template you want to use
})
export class YourComponentController {}
Filter
expot let moduleName = 'filter.module'
export class YourFilterClass {
@Filter({
filterName: 'filter1',
module: moduleName
})
public filter1() {
return (input: any) => {
// do something with the input
};
}
@Filter({
filterName: 'filter2',
module: moduleName
})
public filter2() {
return (input:any) => {
console.log('vnKey', input);
};
}
}
Run
export let moduleName = 'run.module';
export class YourRunConfig {
@Run({
module: moduleName
})
public run1() {
}
}
Config
export let moduleName = 'config.module';
export class YourRunConfig {
@Config({
module: moduleName
})
public config1() {
}
}
Include in module
you can just take the exported module names into your angular.module and build it with webpack