import { Component, EventEmitter, Input, OnInit, Output, ChangeDetectorRef } from '@angular/core'; @Component({ selector: 'onguard-from-to', templateUrl: './from-to.component.html', styleUrls: ['./from-to.component.scss'] }) export class FromToComponent implements OnInit { @Input() siteOptions: T[]; @Input() siteOptionsTo: T[]; @Input() siteBindLabel = 'name'; @Input() siteBindLabelTo = 'name'; @Input() typeOptions = [ 'FROM AND TO', 'TO AND FROM' ]; @Input() selectedTypeOption = 'FROM AND TO'; @Input() selectedFrom: T; @Input() selectedTo: T; @Output() selectedFromChange = new EventEmitter(); @Output() selectedToChange = new EventEmitter(); @Output() typeChage = new EventEmitter(); constructor( private changeDetectorRef: ChangeDetectorRef ) { } ngOnInit(): void { if (!this.siteOptionsTo) { this.siteOptionsTo = this.siteOptions; } if (!this.siteBindLabelTo) { this.siteBindLabelTo = this.siteBindLabel; } } detectChanges(): void { this.changeDetectorRef.detectChanges(); } }