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; } }