fetch data from data.json and display, Ui in progress

Vic
Vic 2 years ago
parent 133aca963a
commit 0f5a841bee

@ -1,13 +1,13 @@
import { TestBed } from '@angular/core/testing';
import { ProductService } from './product.service';
import { HttpService } from './http.service';
describe('ProductService', () => {
let service: ProductService;
describe('HttpService', () => {
let service: HttpService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ProductService);
service = TestBed.inject(HttpService);
});
it('should be created', () => {

@ -0,0 +1,16 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Product } from '../models/product'
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class HttpService {
constructor(private http: HttpClient) { }
getProducts(): Observable<Product[]> {
return this.http.get<Product[]>("../../assets/data.json")
}
}

@ -1,9 +0,0 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class ProductService {
constructor() { }
}
Loading…
Cancel
Save