12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import { Component } from '@angular/core';
- // 引入服务
- import { ActivatedRoute } from '@angular/router';
- // 引入Parse第三方库
- import * as Parse from "parse"
- (Parse as any).serverURL = "http://metapunk.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("PetScience")
- this.science = await query.get(id)
- }
- }
|