diff --git a/src/app/p2/p2.component.html b/src/app/p2/p2.component.html
index d2a8f4faa410055e1ce684c98dbe40ed641bcbcc..8bd1cccb68e0e8fc6e4e6f2a6a0d80e035c635e4 100644
--- a/src/app/p2/p2.component.html
+++ b/src/app/p2/p2.component.html
@@ -5,9 +5,9 @@
問題2、在component.ts設定的buildMessage之訊息無法秀出
-->
- 單品:
- 單價:
- 數量:
+ 單品:
+ 單價:
+ 數量:
你購買 {{ name }} 商品,單價 {{ price }} 元,數量{{ quantity }}元,共計NT${{ price * quantity}} 元 diff --git a/src/app/p2/p2.component.ts b/src/app/p2/p2.component.ts index 7ab1980027ec2e7976c8faaa5890f68859deca0d..8e555f9dc4ef08b85a44ab8b85f8dee4937d956f 100644 --- a/src/app/p2/p2.component.ts +++ b/src/app/p2/p2.component.ts @@ -16,7 +16,7 @@ export class P2Component implements OnInit { datas: Data[] = []; - result: any; + // result = 0; total: any; message = ''; @@ -49,12 +49,13 @@ export class P2Component implements OnInit { } totalPrice(): void { + const result = 0; for ( const i = 0; i < this.datas.length; i++ - ) { const data = this.datas; - this.result = this.result + data[i].total; + ) { const data = this.datas[i]; + result = result + data.total; } - return this.result; + return result; } deleteItem(name, i): void { diff --git a/src/app/p3/p3.component.html b/src/app/p3/p3.component.html index ecf06290038db69ce05a18932630d66c941bff66..f66e4f55312b502226f6edae1a247350af6083fc 100644 --- a/src/app/p3/p3.component.html +++ b/src/app/p3/p3.component.html @@ -1,12 +1,18 @@
題三
-+ + +