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 ....
}
...
}
./client/svc
:
Output in 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);
}
}