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

@Component({
  selector: 'app-dynamic-checkbox',
  templateUrl: './dynamic-checkbox.component.html',
  styleUrls: ['./dynamic-checkbox.component.css']
})
export class DynamicCheckboxComponent implements OnInit {

  @Output() dataValue: EventEmitter<string | Array<any> | boolean> = new EventEmitter();

  @Input() name: string;
  @Input() tag: string;
  @Input() disabled_reg: boolean;
  @Input() disabled_mod: boolean;
  @Input() id: string;
  @Input() label : string;
  @Input() value : string | Array<any> | boolean | Date;
  @Input() isMultiCheck: boolean;
  @Input() arrDataCheck: Array<any>;
  @Input() typeForm : string;

  constructor() {
    this.name = '';
    this.tag = '';
    this.disabled_reg = false;
    this.disabled_mod = false;
    this.id = '';
    this.label = '';
    this.value = false;
    this.isMultiCheck = false;
    this.arrDataCheck = [];
    this.typeForm = '';
  }

  ngOnInit(): void {
  }

  public setValue(event:MatCheckbox) {
    this.dataValue.emit( event.checked );
  }

}
