File

projects/app-base-library/src/lib/angular/services/modal.service.ts

Index

Properties
Methods

Constructor

constructor(bsModalService: BsModalService)
Parameters :
Name Type Optional
bsModalService BsModalService no

Methods

closeModal
closeModal()
Returns : void
openModalWithComponent
openModalWithComponent(options: )
Parameters :
Name Optional
options no
Returns : void
parseOptions
parseOptions(options: )
Parameters :
Name Optional
options no
Returns : void

Properties

Public bsModalRef
bsModalRef: BsModalRef
Type : BsModalRef
Public bsModalService
bsModalService: BsModalService
Type : BsModalService
Private optionsDefault
optionsDefault: object
Type : object
Default value : { data: {}, hasHeader: true, hasFooter: true, hasTitle: true, fullScreen: false, animated: true, keyboard: true, backdrop: true, ignoreBackdropClick: false, }
import { Injectable } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
// import { BsModalRef } from 'ngx-bootstrap/modal/modal-options.class';
import { BsModalRef } from 'ngx-bootstrap/modal';

@Injectable()
export class ModalService {

    public bsModalRef: BsModalRef;

    private optionsDefault = {
        data: {},
        hasHeader: true,
        hasFooter: true,
        hasTitle: true,
        fullScreen: false,
        animated: true,
        keyboard: true,
        backdrop: true,
        ignoreBackdropClick: false,
    };

    constructor(public bsModalService: BsModalService) {

    }

    openModalWithComponent(options ) {
        this.parseOptions(options);
        this.bsModalRef = this.bsModalService.show(options.component , options );
        this.bsModalRef.content.options = options ;
    }

    closeModal() {
        this.bsModalRef.hide();
    }

    parseOptions(options) {
        let defaults:any = JSON.parse(JSON.stringify(this.optionsDefault))
        for (let k in defaults) {
          if (typeof options[k] !== 'undefined') {
               defaults[k] = options[k];
          }
        }
        Object.assign(options, defaults)
    }


}

results matching ""

    No results matching ""