import { Component } from '@angular/core';

// 引入服务
import { ActivatedRoute } from '@angular/router';

// 引入Parse第三方库
import * as Parse from "parse"
(Parse as any).serverURL = "http://web2023.fmode.cn:9999/parse"
Parse.initialize("dev")

@Component({
  selector: 'app-science-detail',
  templateUrl: './science-detail.component.html',
  styleUrls: ['./science-detail.component.scss']
})

export class ScienceDetailComponent {

  //添加评论
  comments: string[] = [];
  comment: string = '';
  currentDate = new Date();
  addComment() {
    console.log(this.comment)
    if (this.comment.trim() !== '') {
      this.comments.push(this.comment);
      this.comment = '';
    }
  }

  //预设值变量
  science: Parse.Object | undefined;
  // 依赖注入
  constructor(private route: ActivatedRoute) {
    // 查询参数获取并赋值给this.science
    this.route.queryParams.subscribe(params => {
      this.getFoodInfoById(params["id"])
    })
  }
  async getFoodInfoById(id: string) {
    let query = new Parse.Query("HrmScience")
    this.science = await query.get(id)
  }


}
