import { Component } from '@angular/core';
import { ViewChild } from '@angular/core';
import { IonContent } from '@ionic/angular';
import { DataService } from '../../../service/data.service';

@Component({
  selector: 'app-home-detail',
  templateUrl: './home-detail.component.html',
  styleUrls: ['./home-detail.component.scss']
})
export class HomeDetailComponent {
  @ViewChild(IonContent)
  CardDetail: any
  content!: IonContent;
  //顶部和底部切换
  scrollToBottom() {
    this.content.scrollToBottom(500);
  }
  scrollToTop() {

    this.content.scrollToTop(500);
  }
  message: string | undefined;

  constructor(private dataService: DataService, private route: ActivatedRoute) {
    this.route.queryParams.subscribe(params => {
      this.CardDetail = params;
      console.log(this.CardDetail)
    })
  }

  //实现数据的传递
  query: any;
  cardDetail: any
  ngOnInit(): void {
    //接受数据，数据中包含图片地址imagesrc，title，Writeinfo，article
    this.message = this.dataService.getMessage();
    this.dataService.currentQuery$.subscribe(query => {
      this.query = query;
    })
    this.loadData();
  }
  async loadData() {
    this.cardDetail = HomePageComponent.prototype.cardDetail;
    console.log(this.cardDetail)
  }
}
import { HomePageComponent } from '../home-page/home-page.component';
import { ActivatedRoute } from '@angular/router';

