5230254 4 months ago
parent
commit
092cede23f
3 changed files with 20 additions and 15 deletions
  1. 1 1
      src/app/tab1/tab1.page.html
  2. 2 2
      src/app/tab2/tab2.page.html
  3. 17 12
      src/app/tab2/tab2.page.ts

+ 1 - 1
src/app/tab1/tab1.page.html

@@ -18,7 +18,7 @@
       </ion-button>  
     </ion-buttons>  
     <!-- (ionBlur)="results=[]" -->
-    <ion-searchbar [debounce]="1000" (ionInput)="search($event)" class="custom-searchbar"></ion-searchbar> 
+    <ion-searchbar placeholder="诗词歌赋,作者,姓名" [debounce]="1000" (ionInput)="search($event)" class="custom-searchbar"></ion-searchbar> 
     <ion-list>
       <ion-item *ngFor="let result of results" (click)="goToDetailPage(result)"
       >

+ 2 - 2
src/app/tab2/tab2.page.html

@@ -15,9 +15,9 @@
   </ion-segment> -->
   <ion-toolbar class="custom-toolbar">
     <!-- <ion-searchbar placeholder="诗词歌赋,作者,姓名" class="custom-searchbar"></ion-searchbar> -->
-    <ion-searchbar placeholder="诗词歌赋,作者,姓名" (ionBlur)="results=[]" [debounce]="1000" (ionInput)="search($event)" class="custom-searchbar"></ion-searchbar> 
+    <ion-searchbar placeholder="诗词歌赋,作者,姓名" [debounce]="1000" (ionInput)="search($event)" class="custom-searchbar"></ion-searchbar> 
     <ion-list class="list" *ngIf="results.length > 0">
-      <ion-item *ngFor="let result of results">
+      <ion-item *ngFor="let result of results"(click)="goToDetailPage(result)">
           <ion-label>{{ result?.get("title") }} {{result?.get("author")}}</ion-label>
       </ion-item>
   </ion-list>

+ 17 - 12
src/app/tab2/tab2.page.ts

@@ -1,4 +1,5 @@
 import { Component,OnInit } from '@angular/core';
+import { NavController } from '@ionic/angular';
 "assets"; [
   "src/favicon.ico",
   "src/assets"
@@ -30,8 +31,6 @@ export class Tab2Page implements OnInit {
   selectedDynasty: string | undefined;
   selectedAuthor: string | undefined;
 
-  constructor() { }
-
   ngOnInit() { }
 
   segmentChanged(event: any) {
@@ -63,24 +62,30 @@ export class Tab2Page implements OnInit {
   }
 
 
-
-  results:Parse.Object[] = []
-  segment = 'tang';  
-  search(event: any) {  
-   console.log('Searching for:', event.detail.value);  
-   if(event?.detail?.value){
+ //搜索下拉框内容
+ results: Parse.Object[] = []
+ segment = 'tang';
+ search(event: any) {
+   console.log('Searching for:', event.detail.value);
+   if (event?.detail?.value) {
      this.loadShigeList(event?.detail?.value)
    }
- }  
- async loadShigeList(search:string){
+ }
+ filteredAuthors: any[] = [];
+
+ async loadShigeList(search: string) {
    let query = new Parse.Query("Shige");
    query.select("title");
-   query.contains("title",search);
+   query.contains("title", search);
    query.limit(5);
    this.results = await query.find();
  }
 
-
+ constructor(private navController: NavController) { }
+ goToDetailPage(item: Parse.Object) {
+   this.results = []
+   this.navController.navigateForward('/detail/' + item.id);
+ }