X-Git-Url: https://juplo.de/gitweb/?p=examples%2Fangular-tutorial;a=blobdiff_plain;f=src%2Fapp%2Fcart.service.ts;fp=src%2Fapp%2Fcart.service.ts;h=aeb5d9e9d9352e1c9abbd2500fa591f7c83be722;hp=0000000000000000000000000000000000000000;hb=02a4f5e131cbac6f4fb820fb8ddd9332892be703;hpb=2e1af39839a0657199c4f4cb339c775a70ccf33d diff --git a/src/app/cart.service.ts b/src/app/cart.service.ts new file mode 100644 index 0000000..aeb5d9e --- /dev/null +++ b/src/app/cart.service.ts @@ -0,0 +1,24 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class CartService { + + items= []; + + constructor() { } + + addToCart(product) { + this.items.push(product); + } + + getItems() { + return this.items; + } + + clearCart() { + this.items = []; + return this.items; + } +}