import { CommonModule } from '@angular/common';
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { IonCard, IonCardContent, IonItem, IonList, IonThumbnail } from '@ionic/angular/standalone';
import { IonLabel, IonSegment, IonSegmentButton, IonSegmentContent, IonSegmentView } from '@ionic/angular/standalone';
import { IonContent, IonHeader, IonTitle, IonToolbar } from '@ionic/angular/standalone';
import { CloudObject, CloudQuery } from 'src/lib/ncloud';

@Component({
  selector: 'app-knowledge-total',
  templateUrl: './knowledge-total.component.html',
  styleUrls: ['./knowledge-total.component.scss'],
  standalone: true,
  imports: [
    IonHeader, IonToolbar, IonTitle, IonContent, IonSegment, IonSegmentButton, IonLabel, IonSegmentView, IonSegmentContent,
    IonThumbnail, CommonModule, IonCard, IonCardContent, IonList, IonItem
  ]
})
export class KnowledgeTotalComponent  implements OnInit {

   constructor(private router: Router) {} 

     goToKnowledge(knowledge: CloudObject){
       const objectId = knowledge.get('title'); // 假设你的主键字段为 'title'
       this.router.navigate(['/tabs/knowledge-page', { id: objectId }]);
     }

    ngOnInit() {
      // 生命周期：页面加载后，运行医生列表加载函数
      this.loadKnowledgeList()
    }
  
    // 创建用于数据列表存储的属性
    knowledgeList:Array<CloudObject> = []
    // 查询并加载医生列表的函数
    async loadKnowledgeList(){
      let query = new CloudQuery("Knowledge");
      this.knowledgeList = await query.find()
    }


}
