import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { ToastController } from '@ionic/angular';
import Parse from "parse";

@Component({
  selector: 'app-tab3-create',
  templateUrl: './tab3-create.page.html',
  styleUrls: ['./tab3-create.page.scss'],
})
export class Tab3CreatePage implements OnInit {

  constructor(private router: Router,private toastController: ToastController) { }

  navigateBackToTab3() {
    this.router.navigate(['/tabs/tab3']);
  }
  saveDraft() {
    this.presentToast('草稿已保存');
  }



  async presentToast(message: string) {
    const toast = await this.toastController.create({
      message: message,
      duration: 2000
    });
    toast.present();
  }
  

  ngOnInit(){

  }
  title: string = "";
  contents: string = "";
  async publish(){
    this.presentToast('内容已发布');
    let InputContentsList =  new Parse.Object("CreatContents");
    InputContentsList.set("title",this.title)
    InputContentsList.set("contents",this.contents)
    
      let result = await InputContentsList.save();
      console.log(result)
  }
}
