Add services
This commit is contained in:
50
src/service/customer.service.ts
Normal file
50
src/service/customer.service.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
export interface Country {
|
||||
name?: string;
|
||||
code?: string;
|
||||
}
|
||||
|
||||
export interface Representative {
|
||||
name?: string;
|
||||
image?: string;
|
||||
}
|
||||
|
||||
export interface Customer {
|
||||
id?: number;
|
||||
name?: string;
|
||||
country?: Country;
|
||||
company?: string;
|
||||
date?: string;
|
||||
status?: string;
|
||||
activity?: number;
|
||||
representative?: Representative;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class CustomerService {
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
getCustomersSmall() {
|
||||
return this.http.get<any>('assets/demo/data/customers-small.json')
|
||||
.toPromise()
|
||||
.then(res => res.data as Customer[])
|
||||
.then(data => data);
|
||||
}
|
||||
|
||||
getCustomersMedium() {
|
||||
return this.http.get<any>('assets/demo/data/customers-medium.json')
|
||||
.toPromise()
|
||||
.then(res => res.data as Customer[])
|
||||
.then(data => data);
|
||||
}
|
||||
|
||||
getCustomersLarge() {
|
||||
return this.http.get<any>('assets/demo/data/customers-large.json')
|
||||
.toPromise()
|
||||
.then(res => res.data as Customer[])
|
||||
.then(data => data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user