From 555c96b662888d074b1e5bc5033a3dc42e93fe09 Mon Sep 17 00:00:00 2001 From: "YLHEALTH\\jackson.li" Date: Fri, 11 Jan 2019 11:01:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=B7=B4=E7=BF=92=E4=B8=89?= =?UTF-8?q?=E7=9A=84stackblitz=E9=80=A3=E7=B5=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/p2/p2.component.html | 6 +++--- src/app/p2/p2.component.ts | 9 +++++---- src/app/p3/p3.component.html | 10 ++++++++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/app/p2/p2.component.html b/src/app/p2/p2.component.html index d2a8f4f..8bd1ccc 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 7ab1980..8e555f9 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 ecf0629..f66e4f5 100644 --- a/src/app/p3/p3.component.html +++ b/src/app/p3/p3.component.html @@ -1,12 +1,18 @@

題三

-

+ + +

作業連結

(目前在stackblitz能做出來,但用自己的電腦卻bulid不起來,無法display):
+ +Stackblitz + + -- 2.26.2