projects
/
examples
/
angular-tutorial
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Formular wie in Tutorial ergänzt -- Funzt nicht
[examples/angular-tutorial]
/
src
/
app
/
cart
/
cart.component.ts
diff --git
a/src/app/cart/cart.component.ts
b/src/app/cart/cart.component.ts
index
500bd05
..
3d3bb99
100644
(file)
--- a/
src/app/cart/cart.component.ts
+++ b/
src/app/cart/cart.component.ts
@@
-1,4
+1,5
@@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit } from '@angular/core';
+import { FormBuilder } from '@angular/forms';
import { CartService } from '../cart.service';
@Component({
import { CartService } from '../cart.service';
@Component({
@@
-9,11
+10,26
@@
import { CartService } from '../cart.service';
export class CartComponent implements OnInit {
items;
export class CartComponent implements OnInit {
items;
+ checkoutForm;
- constructor(private cartService: CartService) { }
+ constructor(
+ private cartService: CartService,
+ private formBuilder: FormBuilder) {
+ this.checkoutForm = this.formBuilder.group({
+ name: '',
+ address: ''
+ });
+ }
ngOnInit() {
this.items = this.cartService.getItems();
}
ngOnInit() {
this.items = this.cartService.getItems();
}
+ onSubmit(customerData) {
+ // Process checkout data here
+ console.warn('Your order has been submitted', customerData);
+
+ this.items = this.cartService.clearCart();
+ this.checkoutForm.reset();
+ }
}
}