Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

schoes/angular-one-decorators

Repository files navigation

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

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published