41 lines
938 B
TypeScript
41 lines
938 B
TypeScript
// #docplaster
|
|
// #docregion imports
|
|
import { Component } from '@angular/core';
|
|
import { FormBuilder } from '@angular/forms';
|
|
|
|
import { CartService } from '../cart.service';
|
|
// #enddocregion imports
|
|
|
|
@Component({
|
|
selector: 'app-cart',
|
|
templateUrl: './cart.component.html',
|
|
styleUrls: ['./cart.component.css']
|
|
})
|
|
// #docregion props-services, submit
|
|
export class CartComponent {
|
|
items;
|
|
checkoutForm;
|
|
|
|
constructor(
|
|
private cartService: CartService,
|
|
private formBuilder: FormBuilder,
|
|
) {
|
|
this.items = this.cartService.getItems();
|
|
|
|
this.checkoutForm = this.formBuilder.group({
|
|
name: '',
|
|
address: ''
|
|
});
|
|
}
|
|
|
|
// #enddocregion props-services
|
|
onSubmit(customerData) {
|
|
// Process checkout data here
|
|
console.warn('Your order has been submitted', customerData);
|
|
|
|
this.items = this.cartService.clearCart();
|
|
this.checkoutForm.reset();
|
|
}
|
|
// #docregion props-services
|
|
}
|