From 0a1f3bf84a37878485ad2da69dfad888beb17759 Mon Sep 17 00:00:00 2001 From: HarveyChou Date: Mon, 7 Nov 2022 16:15:18 +0800 Subject: [PATCH] =?UTF-8?q?ngModel=E5=8A=A0=E5=85=A5=E7=AF=84=E6=9C=AC?= =?UTF-8?q?=E5=8F=83=E8=80=83=E8=AE=8A=E6=95=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/app.component.html | 6 +++--- src/app/app.component.ts | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index dee3748..8990bd1 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,4 +1,4 @@ -查詢條件: - +查詢條件: +
-
查詢條件:{{ condition | json }}
+
查詢條件:{{ result | json }}
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 41d969d..b587276 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,5 @@ import { Component } from '@angular/core'; +import { NgModel } from '@angular/forms'; @Component({ selector: 'my-app', @@ -6,9 +7,10 @@ import { Component } from '@angular/core'; styleUrls: ['./app.component.css'], }) export class AppComponent { - condition = ''; - onSearch(): void { - console.log(`查詢條件:${this.condition}`); + result=''; + onSearch(condition:NgModel): void { + console.log(`查詢條件:${condition.value}`); + this.result=condition.value; } }