焦怡璇 1 éve
szülő
commit
bcd2fb1661

+ 1 - 1
heartvoice-app/src/app/gexinhualiaotian/gexinhualiaotian.component.ts

@@ -11,7 +11,7 @@ import { CommonModule } from '@angular/common'; // 导入 CommonModule
   styleUrls: ['./gexinhualiaotian.component.scss'],
   imports: [
     IonContent, IonButton, IonInput, IonList, IonHeader, IonToolbar, IonTitle, IonButtons, 
-    CommonModule, IonFooter, IonLabel, IonItem, FormsModule
+     IonFooter, IonLabel, IonItem, FormsModule,CommonModule
   ],
 })
 export class GexinhualiaotianComponent implements OnInit {

+ 1 - 5
heartvoice-app/src/app/personality-test/personality-test.component.html

@@ -8,11 +8,7 @@
       <ion-item *ngFor="let question of questionsList">
         <h3>{{ question.get('questionText') }}</h3>
         <ion-list>
-          <ion-item *ngFor="let option of getOptionsForQuestion(question.objectId)">
-            <div class="option-info">
-              <p>{{ option.get('optionText') }}</p>
-            </div>
-          </ion-item>
+
         </ion-list>
       </ion-item>
     </ion-list>

+ 74 - 23
heartvoice-app/src/app/personality-test/personality-test.component.ts

@@ -1,4 +1,4 @@
-
+import { CommonModule } from '@angular/common';
 import { Component, OnInit } from '@angular/core';
 import { IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, IonItem, IonList } from '@ionic/angular/standalone';
 import { CloudObject, CloudQuery } from 'src/lib/ncloud';
@@ -8,37 +8,29 @@ import { CloudObject, CloudQuery } from 'src/lib/ncloud';
   templateUrl: './personality-test.component.html',
   styleUrls: ['./personality-test.component.scss'],
   standalone: true,
-  imports: [IonCard,IonCardHeader,IonCardSubtitle,IonCardTitle,IonCardContent,IonList,IonItem],
+  imports: [IonCard, IonCardHeader, IonCardSubtitle, IonCardTitle, IonCardContent, IonList, IonItem, CommonModule],
 })
-export class PersonalityTestComponent  implements OnInit {
+export class PersonalityTestComponent implements OnInit {
 
   constructor() { }
 
-
   ngOnInit() {
     // 生命周期:页面加载后,运行列表加载函数
-  // 创建用于数据列表存储的属性
-
-    this.loadQuestionsList()
+    this.loadQuestionsList();
   }
 
- 
   questionsList: Array<CloudObject> = [];
   optionList: Array<CloudObject> = [];
-  
 
-   // 查询并加载问题列表的函数
-   async loadQuestionsList() {
+  // 查询并加载问题列表的函数
+  async loadQuestionsList() {
     let query = new CloudQuery("Questions");
     this.questionsList = await query.find();
-    // 加载选项列表
-
-   // 打印加载的问题列表
-   console.log("加载的问题列表:", this.questionsList);
 
+    // 打印加载的问题列表
+    console.log("加载的问题列表:", this.questionsList);
 
     await this.loadOptionsList(); // 调用加载选项的函数
-
   }
 
   // 查询并加载选项列表的函数
@@ -46,23 +38,82 @@ export class PersonalityTestComponent  implements OnInit {
     let query = new CloudQuery("option");
     this.optionList = await query.find();
 
-
-
-     // 打印加载的选项列表
-     console.log("加载的选项列表:", this.optionList);
+    // 打印加载的选项列表
+    console.log("加载的选项列表:", this.optionList);
   }
 
   // 根据问题 ID 获取相关选项
   getOptionsForQuestion(questionId: string) {
     return this.optionList.filter(option => 
-      option.get('question').objectId === questionId
+      option.get('question')?.objectId === questionId
     );
   }
 
 
 
 
+}
+
+
+
+// import { CommonModule } from '@angular/common';
+// import { Component, OnInit } from '@angular/core';
+// import { IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, IonItem, IonList } from '@ionic/angular/standalone';
+// import { CloudObject, CloudQuery } from 'src/lib/ncloud';
+
+// @Component({
+//   selector: 'app-personality-test',
+//   templateUrl: './personality-test.component.html',
+//   styleUrls: ['./personality-test.component.scss'],
+//   standalone: true,
+//   imports: [IonCard,IonCardHeader,IonCardSubtitle,IonCardTitle,IonCardContent,IonList,IonItem,CommonModule],
+// })
+// export class PersonalityTestComponent  implements OnInit {
+
+//   constructor() { }
+
+
+//   ngOnInit() {
+//     // 生命周期:页面加载后,运行列表加载函数
+//   // 创建用于数据列表存储的属性
+
+//     this.loadQuestionsList()
+//   }
+
  
-   
+//   questionsList: Array<CloudObject> = [];
+//   optionList: Array<CloudObject> = [];
+  
 
-}
+//    // 查询并加载问题列表的函数
+//    async loadQuestionsList() {
+//     let query = new CloudQuery("Questions");
+//     this.questionsList = await query.find();
+//     // 加载选项列表
+
+//    // 打印加载的问题列表
+//    console.log("加载的问题列表:", this.questionsList);
+
+
+//     await this.loadOptionsList(); // 调用加载选项的函数
+
+//   }
+
+//   // 查询并加载选项列表的函数
+//   async loadOptionsList() {
+//     let query = new CloudQuery("option");
+//     this.optionList = await query.find();
+
+
+
+//      // 打印加载的选项列表
+//      console.log("加载的选项列表:", this.optionList);
+//   }
+
+//   // 根据问题 ID 获取相关选项
+//   getOptionsForQuestion(question: string) {
+//     return this.optionList.filter(option => 
+//       option.get('question')?.objectId === question
+//     );
+//   }
+// }

+ 2 - 0
heartvoice-app/src/lib/ncloud.ts

@@ -6,6 +6,8 @@ export class CloudObject {
     updatedAt:any;
     data: Record<string, any> = {};
 
+
+
     constructor(className: string) {
         this.className = className;
     }