angular2-resource-and-ajax-interceptor
Version:
angular2-resource-and-ajax-interceptor is angular2 http service helper.
27 lines (26 loc) • 905 B
text/typescript
import {Injectable, Inject} from '@angular/core';
import {Resource} from '../httpresource';
import { Http, Headers, Response} from '@angular/http';
import {AjaxInterceptor} from '../httpresource';
@Injectable()
export class SampleRestService extends Resource {
// resource:Resource
constructor( @Inject(Http) http: Http, ajaxInterceptor:AjaxInterceptor) {
super(http,ajaxInterceptor);
this.config('/user/:id', {id:'@id'}, {
getList: {
method: 'get'
},
getExample: {
method: 'get',
url: '/app/example.json'
},
saveMyData:{
params: { id: '@id'},
url: 'customer/:id',
method: 'post',
header: {'contentType': 'application/json', 'custom-key':'sample value'}
}
});
}
};