import { Component, OnInit } from '@angular/core'; import {BsModalRef} from 'ngx-bootstrap/modal'; @Component({ selector: 'lib-simple-form-modal', templateUrl: './simple-form-modal.component.html', styleUrls: ['./simple-form-modal.component.scss'] }) export class SimpleFormModalComponent implements OnInit { title: string; data; confirmMessage; i18n; formsModel = {} constructor(public bsModalRef: BsModalRef) { } ngOnInit(): void { this.title = this.data.title; this.i18n = this.data.i18n; this.data['formInputs'].forEach(input => { this.formsModel[input.label] = '' }); } onDropdownSelection(event, label, type) { if (type === 'singleSelect') { this.formsModel[label] = event.singleSelectOptions.value; } else { this.formsModel[label] = this.configSelection(event.multiSelectOptions); } } configSelection(array):string { const returnArr = []; array.forEach(item => { if (item.selected) { returnArr.push(item.value); } }); return returnArr.toString(); } onCancel() { this.bsModalRef.hide(); } onConfirm() { this.bsModalRef.hide(); this.bsModalRef.content.onClose.next(this.formsModel); } }