1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import { Component, OnInit } from '@angular/core';
- import { ActivatedRoute, Router } from '@angular/router';
- import { IonBackButton, IonButtons, IonTitle, IonToolbar } from '@ionic/angular/standalone';
- import { IonIcon } from '@ionic/angular/standalone';
- import { IonHeader } from '@ionic/angular/standalone';
- import { IonContent, IonItem, IonList } from '@ionic/angular/standalone';
- import { addIcons } from 'ionicons';
- import { arrowBackOutline } from 'ionicons/icons';
- import { CloudObject, CloudQuery } from 'src/lib/ncloud';
- addIcons({ arrowBackOutline })
- @Component({
- selector: 'app-knowledge-video',
- templateUrl: './knowledge-video.component.html',
- styleUrls: ['./knowledge-video.component.scss'],
- standalone: true,
- imports: [
- IonContent, IonList, IonItem,IonHeader, IonIcon, IonTitle, IonToolbar, IonButtons, IonBackButton
- ]
- })
- export class KnowledgeVideoComponent implements OnInit {
- knowledge: CloudObject | null = null; // 初始化为 null
- constructor(private route: ActivatedRoute, private loute: Router) {}
- ngOnInit() {
- const objectId = this.route.snapshot.paramMap.get('id'); // 获取传递的 ObjectId
- if (objectId) { // 检查 objectId 是否为 null
- this.loadKnowledge(objectId); // 加载对应的知识信息
- } else {
- console.error("No ObjectId found in route parameters.");
- }
- }
- async loadKnowledge(objectId: string) {
- let query = new CloudQuery("videoknowledge");
- query.equalTo("title", objectId); // 根据 ObjectId 查询
- const knowledge = await query.first(); // 获取单条记录
- if (knowledge) {
- this.knowledge = knowledge; // 将获取的知识信息赋值给 knowledge 属性
- } else {
- console.error("Knowledge not found for ObjectId:", objectId);
- // 可以考虑在这里处理找不到知识的情况,比如导航到错误页面或者显示提示
- }
- }
- goToLastPage(){
- this.loute.navigate(['/tabs/knowledge-total'])
- }
- }
|