Shipping-Component mit Data-Fetch über HTTP
[examples/angular-tutorial] / src / app / cart.service.ts
index aeb5d9e..0d68518 100644 (file)
@@ -1,4 +1,5 @@
 import { Injectable } from '@angular/core';
+import { HttpClient } from '@angular/common/http';
 
 @Injectable({
   providedIn: 'root'
@@ -7,7 +8,7 @@ export class CartService {
 
   items= [];
 
-  constructor() { }
+  constructor(private http: HttpClient) { }
 
   addToCart(product) {
     this.items.push(product);
@@ -21,4 +22,8 @@ export class CartService {
     this.items = [];
     return this.items;
   }
+  
+  getShippingPrices() {
+    return this.http.get('/assets/shipping.json');
+  }
 }