Coder Social home page Coder Social logo

kevcjones / ngx-simple-modal Goto Github PK

View Code? Open in Web Editor NEW
51.0 51.0 27.0 12.47 MB

A simple unopinionated framework to implement simple modal based behaviour in angular (v2+) projects.

License: MIT License

JavaScript 5.13% TypeScript 81.95% CSS 1.27% HTML 10.42% SCSS 1.22%
angular component dialog modal modal-components ngx reusable typescript ui

ngx-simple-modal's Introduction

  • 👋 Hi, I’m @kevcjones
  • 👀 I’m interested in solving interesting problems and improving my craft
  • 🌱 I’m currently learning quite a bit of AWS / Opensearch | ElasticSearch / Serverless / CDK / Devops stuff
  • 💞️ I’m looking to collaborate on anything that interests me
  • 📫 How to reach me - @kevcjones or by email is fine too

ngx-simple-modal's People

Contributors

alan-agius4 avatar bikalay avatar blakazulu avatar celsomtrindade avatar grayfox12 avatar kameelyan avatar kevcjones avatar kevcjones-archived avatar kevincjones avatar killer avatar langstra avatar nicolasroehm avatar nnguyenleap avatar sdsanders avatar thesam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngx-simple-modal's Issues

where to change modal fade color ?

I have implemented ngx-simple-modal in which i am opening modal on link click. When modal opens then whole page gets faded with very light black color. I want to make this black color more dark so that my page will get more darker in black and my modal will be more prominent. From where i can change this styling?

Strange behavior when interacting with ng-select module

Hi,

I was trying to migrate from ng2-bootstrap-modal, and i found and strange interaction with the module ng-select (https://github.com/basvandenberg/ng-select).

When i open and select from the dropdown (ng-select) in a modal, the dropdown did not close.
When the ng-select is not in a modal work properlly.

Here you can test this issue:
https://stackblitz.com/edit/angular-tldpgy

Note that, when we use ng2-bootstrap-modal, this not happen.

Thanks in advance

Replace bootstrap css with local css

  • Create a simple-modal.css file for the component
  • Import into demo project
  • Remove bootstrap from demo
  • Update readme to show how CSS works and explain that they can also use bootstrap or other frameworks if they want to.

ComponentFactoryResolver issue

I'm getting the following error with this library:
TypeError: Class constructor ComponentFactoryResolver cannot be invoked without 'new'

It looks like your tsconfig has your target set to es5, and the latest version of angular is using es2015/es6 and it's causing issues with the latest typescript (3.5.4).

    "@angular/animations": "~8.2.4",
    "@angular/common": "~8.2.4",
    "@angular/compiler": "~8.2.4",
    "@angular/core": "~8.2.4",
    "@angular/forms": "~8.2.4",
    "@angular/platform-browser": "~8.2.4",
    "@angular/platform-browser-dynamic": "~8.2.4",
    "@angular/router": "~8.2.4",
    "ngx-simple-modal": "^1.3.24",
    "typescript": "~3.5.3",

[Enhancement] add multiple class to body and/or wrapper

I just want to propose an enhancement.

Instead of adding/removing directly wrapperClass or bodyClass to/from the element list, it would be nice if you can split them to string[] prior to mutating the classList. Currently it's kind of limited to one string only.

mapDataObject doesn't check for null values resulting in a TypeError

mapDataObject(data: T): void {
    data = data || <T>{};
    const keys = Object.keys(data);
    for (let i = 0, length = keys.length; i < length; i++) {
      const key = keys[i];
      if (typeof data[key] === 'object' && typeof this[key] === 'object') {
        Object.assign(this[key], data[key]);
      } else {
        this[key] = data[key];
      }
    }
  }

typeof NULL is unfortunately an object in JavaScript.
When a property inside the modal component defaults to NULL, then the Object.assign function throws an exception trying to assign a value to that null object.

TypeError: "can't convert null to object"

The condition should be changed to this or a similar check that checks for null values.
(data[key] && this[key] && typeof data[key] === 'object' && typeof this[key] === 'object')

The change happened in the following commit: 91f7f4b

Dynamic modal classes

Hi, I'm trying to reproduce iOS style stacked modals, I've been able to do a decent job just with CSS, but there are few issues that bother me:

tg-modal-stack-on

  • ☝️ I'm relying on CSS simple-modal-wrapper:nth-last-child(n) to modify the size/position of the modals. nth-last-child rule that depends on the existence of sibling elements, basically:
    • ...
    • simple-modal-wrapper:nth-last-child(3) { transform: scale(80%); }
    • simple-modal-wrapper:nth-last-child(2) { transform: scale(90%); }
    • simple-modal-wrapper:nth-last-child(1) { transform: scale(100%); }

tg-modals-stack-off

  • ☝️When closing, it doesn't trigger the animation as the CSS hack is based on the presence of the simple-modal-wrapper element. So first it does the slide down & fade animation, then top-most modal is removed, only after that the other modals scale up. It's ugly.

tg-modals-alert

  • ☝️Finally, this won't work with the above explained CSS hack. I want to open a new modal (custom alert) above the already stacked modals, but I don't want the new modal to affect the stacking (scale) of the previously opened ones as it's a different kind of modal. It should just open hover.

I think all these issues could be solved if either wrapperClass or bodyClass from the options object accepted a function. This function would be executed at the moment a modal is instantiated.

It would receive the number of already opened modals (or an array containing the instances) & the instance/class/type of the modal that its being instantiated. Based on these parameter it would be feasible to decide what class the modal should have.

Thanks!

Problem with DefaultSimpleModalOptionConfig

Hi there,

at first: its a great tool and help when dealing a log with dialogs. But I have some problems:

  1. I followed your instractions but I'm unable to setup DefaultSimpleModalOptionConfig. The compiler always says that SimpleModalOptions was not found (file is in the right place.... I guess). So I don't know how to get it to work. Please can you check this and give a working example?
provide:[
  {
    provide: DefaultSimpleModalOptionConfig,
    useValue: {...defaultSimpleModalOptions, ...{ closeOnEscape: true, closeOnClickOutside: true }}
  }
]
  1. when using Bootstrap4 the animations do not work. What's going wrong? Everything else in styling is doing a fine job so far...

Thank you for any help and support,
Lars

Opening the modal programmatically causes change detection error

Hi,

I have an issue when trying to launch the modal programmatically. My use case is to open the modal as soon as my component is ready.

I have used the following config:

SimpleModalModule.forRoot({ container: document.body }),

In my component I implement the AfterViewInit lifecycle hook, and then make a call to create and open the modal:

public ngAfterViewInit() {
               this._SimpleModalService.addModal(..., {...}).subscribe(...)
    }

Here is an example:
https://stackblitz.com/edit/ngx-simple-modal-demo-wwgnqr?file=app%2Fapp.module.ts

I can work around the issue by using a setTimeout around the addModal call, but this is not ideal.

Thanks.

How to dispose instance of modal

I have opened a modal and and closed it back but instance is remaining and i have add few shortcut keys to raise in that model after closing my modal all the tie my call goes to that instance

async showMessagePopup(message, isAlert, isConfirmation, isInformation) {

var isConfirmed = await this.simpleModalService.addModal(AlertFrameworkComponent, {

  popupTitle: 'Hello',
  message: message,
  isAlert: isAlert,
  isConfirmation: isConfirmation,
  isInformation: isInformation
}).toPromise();

return isConfirmed;

}

this.simpleModalService.removeAll();

modal component logic
KeyboardEventRaised = (event: KeyboardEvent, key: string): boolean => {

console.log(document.activeElement.id);

if (document.activeElement.id == 'YesClick' || document.activeElement.id == 'NoClick') {

  event.preventDefault();

  this.RaiseKeyDownEvent(key);
}

return true;

}

TypeScript error for SimpleModalComponent.onClosing

https://github.com/KevCJones/ngx-simple-modal/blob/1e29f0e18d8acb6a5c843250891ff61fa44da71f/src/simple-modal/simple-modal.component.ts#L80

When using this module in a typescript project (v2.6.2) the above method signature produces the following error:

ERROR in [at-loader] ./node_modules/ngx-simple-modal/dist/simple-modal/simple-modal.component.d.ts:13:26
TS7006: Parameter 'component' implicitly has an 'any' type.

I assume it should be typehinted as follows:

onClosing(callback: (component: SimpleModalComponent<any, any>) => Promise<any>): void {

This could be overcome by using skiplibcheck: true but not a good setting to impose on a user.

Angular 9: ngOnDestroy is not triggered (Ivy ng9)

Hello. I'm using angular 9 and have a problem: overridden ngOnDestroy is not triggered so observable is not completed => result is not returned;

Temporary fix of this problem:

    this.result = result;
    this.close();
    this.ngOnDestroy();

Can you check this component with Angular 9?

No dialog shown,seems invisible

Hi
I want to use this component in my app,I've done all setups,I see no error in console but dialog seems invisible to me,after I show it I can't focus something in window so there must be present.
What could cause this?

Also tried your examples , run npm install in demo folder but got errors on install:

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] lint: tslint src/**/*.ts
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Roaming\npm-cache_logs\2018-04-27T09_58_11_725Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: npm run lint && npm run test && ngc
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Roaming\npm-cache_logs\2018-04-27T09_58_11_778Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] postinstall: cd .. && npm i && npm run build && cd demo && rimraf node_modules/ngx-simple-modal && cp -rf ../dist node_modules/ngx-simple-modal
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

thanks

closeOnClickOutside doesn't work when clicking sides

I attempted to migrate from angularx-bootstrap-modal today, but ran into an issue where I could not dismiss the modal by clicking to the left or right of it - only above and below. I know for certain this issue is with the new package because the only thing I swapped was the module, service, and component names.

On a side note, it would be nice if the backdropColor parameter was brought back - it was pretty convenient.

Setup a live demo to link in readme

Always a good one to get people interested is when they see a live version working.

  • Create a live demo somewhere (plunkr worked once)
  • Link into README

@angular-devkit/build-angular 0.803.3

This is an edge case we found with the latest build and wanted this to be up for anyone in the meantime.

@angular-devkit/build-angular 0.803.3 is not compatible with the newer ng-packagr outputted dist. The latest version of angular-devkit/build-angular would break our @angular-elements.

The fix was to update to at least 0.803.8.

Set the scene

This is edge-case stuff, so don't expect you to have this problem

  • We are migrating an ng 1.5 app to Angular (v8) one element at a time.
  • Our elements used ngx-simple-modal and were going fine.
  • Today our builds completely fell apart
    • win machine 1 was building ok but the element in use was throwing out an error much like the one reported here angular/angular#24556. Failed to construct 'HTMLElement': Please use the 'new' operator
    • mac machine 2 was actually breaking during the compiling phase of the element throwing out Cannot read property 'kind' of undefined at isAngularDecoratorMetadataExpression originating from ngx-simple-modal

WTF i said...

Of course, this inconsistency was different npm_modules... i really don't like that ^.

After a lot of NPM tweaking and looking over things that had changed recently + cross-searching for bugs, chasing red herrings we isolated the cause of our problems down to two things.

  1. We'd been doing some work for about 2-3 weeks on locally cached versions of @angular-devkit/build-angular ^0.803.3. After the clearing of modules we both hit the latest, and it didn't work.
  2. We'd recently updated our ngx-simple-modal to use ng-packagr which we discovered didn't play well with our base version of 0.803.3.

Now to try and find out if this is a problem the tooling team would care about? It is pretty edge case after all.

It wasn't until we tried to go from a pre-release angular-element to a new version and build that we found it.

The fix in the end - find the sweet spot

We could only go as far as @angular-devkit/build-angular 0.803.8 before the output changed and our angular-elements stopped working.
Luckily at this version, the latest packagr changes didn't break either with ngx-simple-modal showing Cannot read property 'kind' of undefined at isAngularDecoratorMetadataExpression during the build stage.

Add export of defaultSimpleModalOptions to index.ts

Please add defaultSimpleModalOptions to the main index file.

Now it is:

import { SimpleModalModule } from 'ngx-simple-modal';
import { defaultSimpleModalOptions } from 'ngx-simple-modal/dist/simple-modal/simple-modal-options';

Desired result:

import { SimpleModalModule, defaultSimpleModalOptions  } from 'ngx-simple-modal';

I use it when I overwrite global settings:

SimpleModalModule.forRoot(
      { container: document.body },
      {
        ...defaultSimpleModalOptions,
        {...}
      })

Refactor and document.

From @kevcjones on November 13, 2017 9:47

A quick code review has found some obvious undocumented TODO's e.g. DialogOptions having a file but the exported interface still lives inside dialog.service.ts.

The comments are sometimes a bit redundant, i'd like to generate some documentation, which will feed from the comments.

This should help me get a firmer grasp on the code base so i can take on community issues and requests. I will pull from the original REPO for issues when the ones here have been handled

Copied from original issue: kevcjones-archived/angularx-bootstrap-modal#4

Doesn't work in Angular 8.1 --prod mode

I receive an error when i build with --prod option. Without, it works.
I am getting the following Java-Script errormessage:

"this.viewContainer is undefined"

Prevent overlay stacking when multiple windows showing

Me again. Sorry, but hopefully it's a less painful question.

I noticed that with your local styles, when we show multiple windows at the same time, the semi-opaque overlay is also duplicated with the result that the more windows we show, the darker it gets (down to black within about 4 windows).

Is there any way to prevent this stacking effect so that it's only the windows that are repeated rather than the screen overlay? Or do I need to resolve this in the CSS somehow?

Configuration improvements

  • Improve / refactor how the config is parsed (clean up code)
  • Remove css responsible control from .js config
  • Explore new config options

Hide Modal visibility on page redirect

I am using Angular 4 to build my application. When i redirect to another url that is from one component to another component if my modal popup is opened then it should not be visible in redirected component.
Let suppose i have 2 components
HelloWorkldComponent
ByeComponent

In HelloWorkldComponent i have raised a modal with enabling the background.
Now from routing am trying to redirect to my ByeComponent, then my modal popup is visible in ByeComponent component as well, but i need modal popup not to be visible in ByeComponent. How can i resolve this. Please help me.

Thanks in advance.

changing global default options

Hi,
I want to have some global options for all modals, for example "closeOnEscape: true,
closeOnClickOutside: true,". Don´t want to specify that on every .addModal() call, it seems redundant.
I can´t see an obvious way to do this.
These default options seem to be set in SimpleModalHolderComponent, so it looks like they can´t be overriden at extending component either.

....
import { defaultModalOptions, SimpleModalOptions } from './simple-modal-options';
....

// assign options refs
    _component.options = options = Object.assign({}, defaultModalOptions, options);

Add Travis CI

This is in preparation for #2 but also i think useful to automate our build scripts and check the linting is obeyed before we merge a PR.

Pressing Enter Key causes duplicate windows

If I open a modal, then press the enter key on the keyboard, that modal is opened again along with the blocking container, causing it to get darker and open new windows on every press of enter.

Opening modal in dom

Apologies in advance, this is not an issue but a support request...
I love this lib, it´s great for most use cases. I´m just missing the option for a more "specific" use case when you don´t want to create a component (extending SimpleModalComponent) but rather just include it in your parent component. This is the way other libs (for ex Angular Bootstrap 3 Modal Component work. I´d really like to have the best of both worlds, have components for alerts, confirms, etc as you do but also to pull the modal from DOM in a more Bootstrapish approach.

My approach to do this is to create a "DomComponent" with "" selector that in turn calls SimpleModalService to open it´s content (through a GenericModalComponent). I´ll post the code i´m using, but it might be a totally wrong approach, so I can point out the problems i´m encountering....

In parent component ....

 <button type="button" class="btn btn-default" (click)="domModal.open()">Open
      <b>&lt;modal&gt;</b> in dom.</button>
    <pre>inputText: {{inputText}}</pre>

    <modal (onClose)="event_here?()" title="Modal title" #domModal>
      <modal-header>Hi this is head of modal.
        <b>Bold</b>
      </modal-header>
      Modal body here.... this is the first modal.
      <input type="text" evInput evIcon="fa-android" [(ngModel)]="inputText" />
      <modal-footer>Hi this is modal footer.
        <button class="btn btn-success" (click)="modalInnerSubmit(domModal)">InnerSubmit</button>
      </modal-footer>
    </modal>

And DomModal component:
(BaseModalComponent extends SimpleModalComponent).

@Component({
  selector: 'modal',
  template: `<ng-template #domModalContent>
  <ng-content ></ng-content>
  </ng-template>
  <ng-template #footer >
  <ng-content select="modal-footer"></ng-content>
  </ng-template>
  <ng-template #header >
  <ng-content select="modal-header"></ng-content>
  </ng-template>`
})
export class DomModalComponent extends BaseModalComponent  implements GenericModalModel, OnInit, OnDestroy {
  @ViewChild('domModalContent') content: TemplateRef<any>;
  @ViewChild('footer') footer: TemplateRef<any>;
  @ViewChild('header') header: TemplateRef<any>;
  openM: Observable<any>;
  modalIndex: number;
  openModal: SimpleModalService;
  constructor(private modalService: SimpleModalService,
    private _componentFactoryResolver: ComponentFactoryResolver) {
    super();
  }
   private closerCallback(modal){
    // does not work... modal is opener (this) not the one service opened.
    // this.modalService.removeModal(modal);
    const openModals = this.modalService.modalHolderComponent.modals;
    const index = _.indexOf(openModals, this.openModal);
    const activeComponent = this.modalService.modalHolderComponent.modals[index];
    if (activeComponent) {
      activeComponent.close();
    }
  }

  open() {
    // how many of this.properties are attributes to pass along to creation?
    const attrObject = this.attributesToObject() || {};

    this.openM = this.modalService.addModal(GenericModalComponent,
      {...attrObject},
      {closeOnClickOutside: true}
     );
     // this never fires...
     this.openM.subscribe((isConfirmed) => {
      if (isConfirmed) {
        this.close();
      }
    });
     // Might fail because modalHolderComponent  is private in service
     const openModals = this.modalService.modalHolderComponent.modals;
     this.openModal = _.last(openModals);
     this.modalIndex = openModals.length ? openModals.length - 1 : null;
  }
  attributesToObject() {
    const availableAttrs = Object.keys(this);
    // attributes we want to parse...
    const attrObject = new GenericModalModelClass();
    for (const attr of Object.keys(attrObject) {
       if (this[attr]) {
        attrObject[attr] = this[attr];
      }
    }
    return attrObject;
  }
}

I have major issues here.
I can open the modal just fine using Service. But i have no reference to the opened Modal, the only way i can seem to access it is by " this.modalService.modalHolderComponent.modals;" which seems wrong and even more since it´s a private var.
I implemented "closerCallback" to be able to extend, since DomModal is not opened through service... here is where i close the opened modal... But "this.modalService.removeModal();" needs the opened modal which i can´t seem to target, so I hackishly target modalHolderComponent to get the last opened modal.
There must be a better way (for sure ;) and even if my approach is halfway alright (doubt it) there must be a way of interacting (closing, etc) with the opened modal through Promises, Observables... Triggering the opened modal close() and resolving without direct ref to modalHolderComponent....

I´d really love to implement this to cover all cases. Thanks in advance!!.

error when installing

Hi, i have this error when I compiled my project. but in VsCode, the module is founded.

ng serve
10% building 3/3 modules 0 activeℹ 「wds」: Project is running at http://localhost:4200/webpack-dev-server/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: 404s will fallback to //index.html

chunk {default~components-components-module~src-app-content-pages-pages-module} default~components-components-module~src-app-content-pages-pages-module.js, default~components-components-module~src-app-content-pages-pages-module.js.map (default~components-components-module~src-app-content-pages-pages-module) 1.78 MB  [rendered]
chunk {main} main.js, main.js.map (main) 212 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 293 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 9.18 kB [entry] [rendered]
chunk {scripts} scripts.js, scripts.js.map (scripts) 394 kB [entry] [rendered]
chunk {src-app-content-pages-pages-module} src-app-content-pages-pages-module.js, src-app-content-pages-pages-module.js.map (src-app-content-pages-pages-module) 39.8 kB  [rendered]
chunk {styles} styles.js, styles.js.map (styles) 1.36 MB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 5.06 MB [initial] [rendered]
Date: 2020-03-05T09:40:31.592Z - Hash: a5f45200675dac36f323 - Time: 14756ms

WARNING in /Users/lapezealexis/Downloads/listen/theme/src/app/config/layout.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.

WARNING in /Users/lapezealexis/Downloads/listen/theme/src/environments/environment.prod.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.

ERROR in ./src/app/content/layout/layout.module.ts
Module not found: Error: Can't resolve 'ngx-simple-modal/simple-modal/simple-modal-options' in '/Users/lapezealexis/Downloads/listen/theme/src/app/content/layout'
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
ℹ 「wdm」: Failed to compile.```

can you help me please ?

Metadata version missmatch. Found version 4, expected 3

Whenever I add a new module to my project I get a compiler error stating that this dependency has a metadata version mismatch (I think it's complaining about my Angular version). I have Angular v 4 and it expects Angular v 3. I looked through the npm page for the package and it seems to say that it should work with any version of Angular 2+. In the past I have resolved this by deleting my node_modules folder and doing a fresh install. This time, however, it seems to not be working.

Using angular 4.2.4
Using ngx-simple-modal 1.3.12

Any tips or guidance would be greatly appreciated.

closeOnClickOutside: true prevents click events to propagate

If I set the closeOnClickOutside flag to true, the code behind disables event propagation. This is not a good practice and could make other libs that depend on clicks to not work properly.

I created a small demo to ilustrate the problem:
https://stackblitz.com/edit/ngx-simple-modal-demo-wlmjv1

Maybe you could fix it using some solution like one in this link:
https://stackoverflow.com/questions/40107008/detect-click-outside-angular-component

Add 'modal' and 'fade' classes to configuration.

Is it possible to add the names of these classes (or maybe all template html) in component definition below to configuration?

@Component({
  selector: 'simple-modal-wrapper',
  template: '
    <div #wrapper class="modal fade" [ngStyle]="{display:'block'}" role="dialog">
        <ng-template #viewContainer></ng-template>
    </div>'
})

Angular 6 and RxJs 6 changes

After update to Angular 6 we get this errors trying to build the app:

ERROR in node_modules/ngx-simple-modal/dist/simple-modal/simple-modal.component.d.ts(2,10): error TS2305: Module '"D:/Git/Workspace/PREF-X/FrontEnd/node_modules/rxjs/Observable"' has no exported member 'Observable'.

node_modules/ngx-simple-modal/dist/simple-modal/simple-modal.service.d.ts(2,10): error TS2305: Module '"D:/Git/Workspace/PREF-X/FrontEnd/node_modules/rxjs/Observable"' has no exported member 'Observable'

Changing :
import { Observable } from 'rxjs/Observable';
to:
import { Observable } from 'rxjs';

Solve the problem

Error opening Modal when exporting Web Components

Upon exporting Web Components on Angular 7, modals stop working. When an action tries to open a modal, I get the following error:

ERROR TypeError: Cannot read property 'hostView' of undefined
    at e.get [as container] (main.js:1)
    at e.createSimpleModalHolder (main.js:1)
    at e.addModal (main.js:1)
    at deleteRow (main.js:1)
    at Object.handleEvent (main.js:1)
    at Object.handleEvent (main.js:1)
    at Object.handleEvent (main.js:1)
    at yf (main.js:1)
    at Kf.r (main.js:1)
    at HTMLAnchorElement.t (main.js:1)

Upon disabling build minification, the error leads to this line:
this.container = componentRootViewContainer.hostView.rootNodes[0];

I have tried to brute-force the issue and it seems it has something to do with how the SimpleModalModule is declared in app.module.ts - SimpleModalModule.forRoot({container: "modal-container"}). Upon building a web component, the root is missing, thus this hostView is undefined and modal can't inject itself into the page. Any ideas how to circumvent this issue would be most welcome. I have spent quite a lot of time on the issue, but as it is a purely ngx-simple-modal -related issue, Internet hasn't helped much.

How to work on background when modal is opened

I am new to modals in angular. my requirement is to work on background when my modal popup is opened and i need to set my custom styles to the modal. But couldn't apply when i am creating separate css for each components modals. Effecting all modals if i declare css globally

ng 8 production error

hi, thank you for your cool component,
i get this error only in production, and it does not mater what is inside the modal

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'split' of undefined
TypeError: Cannot read property 'split' of undefined
at t.toggleWrapperClass (main.bfa15500980a1678c13f.js:1)
at main.bfa15500980a1678c13f.js:1
at e.invoke (polyfills.733a0246794ccdcf00a6.js:1)
at Object.onInvoke (main.bfa15500980a1678c13f.js:1)
at e.invoke (polyfills.733a0246794ccdcf00a6.js:1)
at t.run (polyfills.733a0246794ccdcf00a6.js:1)
at polyfills.733a0246794ccdcf00a6.js:1
at e.invokeTask (polyfills.733a0246794ccdcf00a6.js:1)
at Object.onInvokeTask (main.bfa15500980a1678c13f.js:1)
at e.invokeTask (polyfills.733a0246794ccdcf00a6.js:1)
at j (polyfills.733a0246794ccdcf00a6.js:1)
at polyfills.733a0246794ccdcf00a6.js:1
at e.invokeTask (polyfills.733a0246794ccdcf00a6.js:1)
at Object.onInvokeTask (main.bfa15500980a1678c13f.js:1)
at e.invokeTask (polyfills.733a0246794ccdcf00a6.js:1)
at t.runTask (polyfills.733a0246794ccdcf00a6.js:1)
at y (polyfills.733a0246794ccdcf00a6.js:1)
at t.invokeTask (polyfills.733a0246794ccdcf00a6.js:1)
at invoke (polyfills.733a0246794ccdcf00a6.js:1)
at n.args. (polyfills.733a0246794ccdcf00a6.js:1)

Issue with Bootstrap 4

My project was previously using Bootstrap 3 which had no problems. After changing the CSS reference to Bootstrap 4 -- no more worky.

I've also tried to get the demo from this repo working with Bootstrap 4 but it has the same problem. The dialog flashes (not visible to the eye) and then the page is unresponsive.

Anyone successfully using this with Bootstrap 4. I may have to change directions because I'm running short on time.

ngOnDestroy

Can you add to docs about ngOnDestroy override? Cause if i implement ngOnDestroy method in my modal component, observable.next not working. And listener doesnt know about event from modal window

Model does not trap focus

I have found that when a modal is open, I can tab out of the modal element and into other parts of the page and interact with elements using the keyboard. I have fixed some of this by setting a working flag to disable buttons when the modal is open, but it is a bit cumbersome and not perfect... hyperlinks, for example, can still be triggered. This make for a strange experience because the router changes the content behind the modal, but the modal stays open. I haven't had a lot of time to dig into this yet, but was wondering if you were aware of this limitation and have any ideas of ways to work around it. It would be great if there was a global setting to trap the focus to the modal-content element. I know Bootstrap Modal has a way to do this, but I'm not sure how it works. If I get a chance, I will research it further.

Error encountered resolving symbol values statically. - FU node_modules

Had a build error re-emerge.

client?692d:119 Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 194:50 in the original .ts file), resolving symbol NgModule in ...

Initially i thought this was a meta data issue in our code, but i think this comment might be onto something. Its because we have node_modules in the npm package

angular/angular-cli#3707 (comment)

This worked... so i'll be thinking about how to do a better npm package that only contains the dist folder files and a modified index / package.json

Error with addModal in prod build

This may be an ID10T error but when I build my app for prod (ng build --prod) I get the following error whenever I try to call addModal

ERROR TypeError: Cannot read property 'hostView' of undefined
at e.get [as container] (main.3cf43099cd0aeae4fae7.bundle.js:1)
at e.createSimpleModalHolder (main.3cf43099cd0aeae4fae7.bundle.js:1)
at e.addModal (main.3cf43099cd0aeae4fae7.bundle.js:1)

I've tried with and without defining the container as document.body

Worth noting, I have recently transitioned from ng2-bootstrap-modal. Also, everything works fine if I don't build for --prod.

Any help would be appreciated.

Not working with Angular 11

I use Angular 11.0.9 and "ngx-simple-modal": "^1.4.14" but it doesn't work.

Error: node_modules/ngx-simple-modal/simple-modal/simple-modal.module.d.ts:5:97 - error TS2314: Generic type 'ModuleWithProviders' requires 1 type argument(s).

Are there any plans to update the lib soon?

Thanks!!

Timing issues in ErrorHandler?

Hi,

I've been successfully using your module to show error dialogs in my Angular 5 app. Everything was working fine until I tried to use it in a subclass of ErrorHandler. When I did this the modal would appear but none of the bound data would appear, the modal was visible but with nothing in it except the hard-coded HTML.

I realised that the data would appear if the application was forced to update. It seems like things may be happening in the wrong order?

handleError(error: any) {
    const notificationService = this.injector.get(NotificationService);

    notificationService.showErrorDialog(error.message);
    console.log('Error occurred: \n\n' + error.message);

    const app = this.injector.get(ApplicationRef);
    setTimeout(() => { app.tick(); }, 150);
  }
 showErrorDialog( message: string, callback?: Function) {
    return this.modalService.addModal(DialogComponent, {
      title: 'An error occurred',
      message: message,
    });
  }

Having the application tick instantly makes the data display but I have a translation service which has not finished providing the translations unless I give at least 150ms before the tick.

Apologies if I'm doing something stupid - I'm fairly new to Angular. Obviously I can use the tick solution but it's messy and I will have to find a way to prevent the window from appearing until it's been drawn properly.

The module is nice so I'll be super grateful for any help you can give.

Add credits to readme to original authors repo

Purely for ethical reasons, a footnote credit to say we took a long dormant repo X as a starting point and ran with it in our own direction. For better or worse, its now become something else... so we broke away.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.