button-group.component.ts 783 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { Component, Input, Output, EventEmitter, OnInit, OnChanges } from '@angular/core';
  2. @Component({
  3. selector: 'app-button-group',
  4. templateUrl: './button-group.component.html',
  5. styleUrls: ['./button-group.component.scss']
  6. })
  7. export class ButtonGroupComponent implements OnInit, OnChanges {
  8. @Input()
  9. meta: StringMap<any>;
  10. @Output()
  11. call: EventEmitter<string> = new EventEmitter<string>();
  12. buttons: StringMap<any>[];
  13. readonly componentName = 'ButtonGroupComponent'; // For AOT compatibility, as class names don't survive minification
  14. ngOnInit() {
  15. this.buttons = this.meta.meta;
  16. }
  17. ngOnChanges() {
  18. this.buttons = this.meta.meta;
  19. }
  20. handle(fnId: string, e: Event): void {
  21. e.preventDefault();
  22. (e.target as HTMLElement).blur();
  23. this.call.emit(fnId);
  24. }
  25. }