import {Component, OnInit, Input, OnChanges, Output, EventEmitter, OnDestroy} from '@angular/core'; import {FilterInfo} from '../types/filter-info'; @Component({ selector: 'ics-toggle', templateUrl: './toggle.component.html', styleUrls: ['./toggle.component.scss'] }) export class ToggleComponent implements OnInit, OnChanges, OnDestroy { @Input() color; @Input() checked; @Input() disabled; @Input() text: string; @Output() isChecked: EventEmitter; @Input() filterInfo: FilterInfo; @Input() filterData: any[]; @Output() instantiated: EventEmitter; @Output() filterSet: EventEmitter; constructor() { this.isChecked = new EventEmitter(); this.instantiated = new EventEmitter(); this.filterSet = new EventEmitter(); } ngOnInit() { if (this.color === undefined || this.color === null) { this.color = 'accent'; } if (this.checked === undefined || this.checked === null) { this.checked = false; } if (this.disabled === undefined || this.disabled === null) { this.disabled = false; } if (this.text === undefined || this.text === null) { this.text = ''; } this.resolve(); // filter instantiated console.log('sending the notification' + this.filterInfo.name); this.instantiated.emit(this.filterInfo); } ngOnChanges() { } resolve() { this.filterSet.emit(this.filterInfo); } notify() { this.isChecked.emit(!this.checked); } ngOnDestroy() { } }