shlomiassaf / ngx-modialog

Modal / Dialog for Angular
http://shlomiassaf.github.io/ngx-modialog
MIT License
686 stars 241 forks source link

BSModalContext not found in ngx-modialog/plugins/bootstrap #430

Open upendrasengarmbwk opened 6 years ago

upendrasengarmbwk commented 6 years ago

I'm submitting a ... [x] bug report [ ] feature request [ ] question about the decisions made in the repository

I'm using latest version but unable to create a custom component as modal dialg altough it was working with older version angular2-modal.

import { Modal, BSModalContext } from 'ngx-modialog/plugins/bootstrap';

ERROR in src/app/app.module.ts(33,38): error TS2307: Cannot find module 'ngx-modialog/plugins/bootstrap'. src/app/components/requests/popups/approved-request/approved-request.component.ts(4,39): error TS2307: Cannot find module 'ngx-modialog/plugins/bootstrap'.

Code Sample

    import { Component, OnInit } from '@angular/core';
    import { Overlay, DialogRef, ModalComponent, CloseGuard } from 'ngx-modialog';
    import { Modal, BSModalContext } from 'ngx-modialog/plugins/bootstrap';`
    export class CustomModalContext extends BSModalContext {
          public modalData: any;
    }
    @Component({
             selector: 'modal-content',
              templateUrl: './approved-request.component.html'
     })

    export class ApprovedRequestModal implements OnInit, CloseGuard, 
      ModalComponent<CustomModalContext> {
      context: CustomModalContext;
      public modalData: any;
      public img;

     constructor(
        public dialog: DialogRef<CustomModalContext>,
      ) {
        console.log(dialog.context);
        this.context = dialog.context;
        dialog.setCloseGuard(this);
    }
    ngOnInit() {
    }

    beforeDismiss(): boolean {
        return false;
    }

    beforeClose(): boolean {
        return false;
    }

    close() {
    }
}
zerocewl commented 6 years ago

Try this solution...

https://github.com/shlomiassaf/ngx-modialog/issues/398

That's a problem with Typescript 2.5.3. If you go back to 2.5.2, it should work. I had the same issue.