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

@Component({
  selector: 'app-data-table',
  templateUrl: './data-table.component.html',
  styleUrls: ['./data-table.component.css']
})
export class DataTableComponent implements OnInit {
  @Input() data: { headers: any, rows: any, dialogData: { title: string, text: string } };
  @Output() edit = new EventEmitter<number>();
  @Output() delete = new EventEmitter<number>();
  deleteIndex: number;

  constructor() { }

  ngOnInit() {
  }

  editItem(index) {
    this.edit.emit(index);
  }

  confirmDelete() {
    console.log(this.deleteIndex);
    this.delete.emit(this.deleteIndex);
  }

}
