### File

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

### Index

###### Properties

- Public bsModalRef
- Public bsModalService
- Private optionsDefault

###### Methods

- closeModal
- openModalWithComponent
- parseOptions

### Constructor

`constructor(bsModalService: BsModalService)`
Defined in projects/app-base-library/src/lib/angular/services/modal.service.ts:21

Parameters :

Name | Type | Optional
bsModalService | `BsModalService` | no

### Methods

closeModal
`closeModal()`
Defined in projects/app-base-library/src/lib/angular/services/modal.service.ts:33
Returns : `void`

openModalWithComponent
`openModalWithComponent(options: )`
Defined in projects/app-base-library/src/lib/angular/services/modal.service.ts:27

Parameters :

Name | Optional
options | no

Returns : `void`

parseOptions
`parseOptions(options: )`
Defined in projects/app-base-library/src/lib/angular/services/modal.service.ts:37

Parameters :

Name | Optional
options | no

Returns : `void`

### Properties

Public bsModalRef
`bsModalRef: `BsModalRef``
Type : `BsModalRef`
Defined in projects/app-base-library/src/lib/angular/services/modal.service.ts:9

Public bsModalService
`bsModalService: `BsModalService``
Type : `BsModalService`
Defined in projects/app-base-library/src/lib/angular/services/modal.service.ts:23

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, }`
Defined in projects/app-base-library/src/lib/angular/services/modal.service.ts:11

    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 ""