diff --git a/src/app/P2.html b/src/app/P2.html
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/src/app/app.component.html b/src/app/app.component.html
index d9292d73ce06614208d6abd0a11311094cb9bb17..65ed4b35776df30b930fd65b707f9bdaf8f9ff5c 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -3,10 +3,10 @@
單品:
單價:
數量:
+ 你購買 {{ name }} 商品,單價 {{ price }} 元,數量{{ quantity }}元,共計NT${{ price * quantity}} 元
-{{message}}
-
+
@@ -18,9 +18,9 @@
小計 |
-
+
- |
+ |
{{ message.name }} |
{{ message.price }} |
{{ message.quantity }} |
@@ -29,14 +29,7 @@
加總 |
- |
+ {{total}} |
-
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 7ff3fd279763541bc1e422340ea444bece30b830..ed74540f9d328d179d9b1ec4d6d5ea80e57d81a5 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -16,33 +16,23 @@ export class AppComponent {
messages: Message[] = [];
+ result = 0;
+
addMessage(): void {
// 防呆,避免名稱或內容是空值時也可以留言
if (
- !this.name.trim() && !this.messages.trim() && !this.quantity.trim()
+ !this.name.trim() && !this.price.trim() && !this.quantity.trim()
) {
return;
}
-
// 用名稱跟內容產生一個留言的資料物件
const message = new Message(this.name, this.price, this.quantity);
-
// 將留言的資料物件放進容器裡
this.messages.push(message);
}
-
- total():void {
+ deleteItem(): void {
+ alert('清空啦');
}
-
- buildMessage(): void {
-
- }
-
- remove(): void {
- this.messages.remove(new Message);
- }
-
-
}