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

@Component({
  selector: 'neu-button',
  templateUrl: './neu-button.component.html',
  styleUrls: ['./neu-button.component.css']
})
export class NeuButtonComponent implements AfterViewInit {

  @Input("color") color:string;
  @Input("size") size:string;
  @Input("shape") shape:string;
  @Input("type") type:string;
  @Input("routerLink") routerLink:any;
  @Input("disabled") disabled:boolean;
  @Output("neu_click") neu_click:EventEmitter<any> = new EventEmitter();

  @ViewChild("button") button:ElementRef;

  constructor() { }

  ngAfterViewInit() {
    //type
    if(this.type!=null) this.button.nativeElement.setAttribute("type", this.type);
    else this.button.nativeElement.setAttribute("type", "button");

    //routerLink
    if(this.routerLink) this.button.nativeElement.setAttribute("routerLink", this.routerLink);
  }

  onClick() {
    this.neu_click.emit();
  }

}
