

import { Component } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { Router } from '@angular/router';


@Component({
  selector: 'app-page-home',
  templateUrl: './page-home.component.html',
  styleUrls: ['./page-home.component.scss']
})
export class PageHomeComponent   {


  articleForm: FormGroup;

  constructor(private router: Router) {
    this.articleForm = new FormGroup({
      title: new FormControl(),
      content: new FormControl()
    });
  }

 

  article = {
    title: '',
    content: ''
  };

  submitArticle() {
    // 在这里处理发布文章的逻辑
    console.log('Article submitted:', this.article);
  }




  articles: Article[] = [
    {
      id:1,
      title: '拜错神',
      content: '这算是传播正能量了吧。'
    },
    {
      id:2,
      title: '阴阳合同',
      content: '算命的给了我一个阴阳合同，让我深夜到一个公墓的十字路口烧掉。。。'
    },
    {
      id:3,
      title: '文言故事几则：',
      content: '广西一偏僻小村常有。。。'
    },
    {
      id:4,
      title: '《故事会》精选',
      content: '一个单位领导叫胡不字，签字喜欢用毛笔。。。'
    },
    {
      id:5,
      title: '《道士不好惹》',
      content: '深山之中有座道观，观内只有一老一小两个道士。。。'
    },
    {
      id:6,
      title: '河豚宴',
      content: '民国时期，扬州一带盛行吃河豚宴。。。'
    },
    {
      id:7,
      title: '小镇皇帝的故事',
      content: '话说西北桃源镇有一个贺老头。。。'
    }
  ];

  

  goToArticle(articleId: number) {
    this.router.navigate(['/article', articleId]);
  }
}

interface Article {
  id: number;
  title: string;
  content: string;

}