import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'

@Component({
  selector: 'app-page9',
  templateUrl: './page9.component.html',
  styleUrls: ['./page9.component.css']
})
export class Page9Component implements OnInit {
  @Input() curPageData: Array<any>
  @Input() hasMate: boolean
  @Output() getAllAnswer = new EventEmitter<any>()
  curAllQues: Object
  constructor() {}

  ngOnInit() {
    this.curAllQues = {}
    console.log(this.curPageData)
  }
  getAnswer(question, options) {
    console.log('page9', question, options)
    const questionId = question['questionId']
    this.curAllQues[questionId] = options
    const questions = Object.keys(this.curAllQues).map(questionId => {
      return { questionId, options: this.curAllQues[questionId] }
    })
    const ret = {
      pageId: 9,
      questions
    }
    this.getAllAnswer.emit(ret)
  }
}
