CartService und Buy-Button auf Detail-Seite hinzugefĆ¼gt
[examples/angular-tutorial] / src / app / cart.service.ts
1 import { Injectable } from '@angular/core';
2
3 @Injectable({
4   providedIn: 'root'
5 })
6 export class CartService {
7
8   items= [];
9
10   constructor() { }
11
12   addToCart(product) {
13     this.items.push(product);
14   }
15
16   getItems() {
17     return this.items;
18   }
19
20   clearCart() {
21     this.items = [];
22     return this.items;
23   }
24 }