projects
/
examples
/
angular-tutorial
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Shipping-Component mit Data-Fetch über HTTP
[examples/angular-tutorial]
/
src
/
app
/
cart.service.ts
diff --git
a/src/app/cart.service.ts
b/src/app/cart.service.ts
index
aeb5d9e
..
0d68518
100644
(file)
--- a/
src/app/cart.service.ts
+++ b/
src/app/cart.service.ts
@@
-1,4
+1,5
@@
import { Injectable } from '@angular/core';
import { Injectable } from '@angular/core';
+import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root'
@Injectable({
providedIn: 'root'
@@
-7,7
+8,7
@@
export class CartService {
items= [];
items= [];
- constructor() { }
+ constructor(
private http: HttpClient
) { }
addToCart(product) {
this.items.push(product);
addToCart(product) {
this.items.push(product);
@@
-21,4
+22,8
@@
export class CartService {
this.items = [];
return this.items;
}
this.items = [];
return this.items;
}
+
+ getShippingPrices() {
+ return this.http.get('/assets/shipping.json');
+ }
}
}