import { Directive, EventEmitter, HostListener, Input, Output } from '@angular/core';
import { SortType } from './sort-header.component';

@Directive({
  selector: '[pagerSort]'
})
export class SortDirective {
  @HostListener('click') 
  onClick() {
    if (!this.enabled) return;
    let nextOrder : SortType = this.order == 'desc' ? 'asc' : 'desc';
    this.onSortChange.emit(nextOrder);
  }



  @Input() enabled = true;
  @Input() order: SortType = null;

  @Output() onSortChange = new EventEmitter<SortType>()


  constructor() { }

}

