1.0.5 • Published 7 years ago

ccd-ng2 v1.0.5

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

Build Status

CCD-NG2

Provides @ngGenSvc decorator that generates angular2 services for a given CCController

Example

@ngSvcGen('./client/svc', true)
class HelloCtrl extends CCController{
    @get('/hello/:name')    
    helloWorld(req, res){
        return `hello ${req.params.name}`
    }

    @post('/:id')    
    doSomething(req, res){
        return ....
    }
    ...
}

Output in ./client/svc:

import { Injectable } from '@angular/core';
import { SimpleRestService } from 'ccNgRest';

@Injectable()
export class HelloCtrlSvc{
    constructor(private rest: SimpleRestService){}

    helloWorld(name){
        return this.rest.get('/hello/'+name);
    }

    doSomething(id, payload){
        return this.rest.post('/'+id, payload);
    }
}