kevcjones / ngx-simple-modal

A simple unopinionated framework to implement simple modal based behaviour in angular (v2+) projects.
MIT License
52 stars 27 forks source link

Problem with DefaultSimpleModalOptionConfig #50

Closed elementalTIMING closed 5 years ago

elementalTIMING commented 5 years ago

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 }}
    }
    ]
  2. 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

kevcjones-archived commented 5 years ago

Seems like it's regression season again. I guess my first question is have you looked at the readmes link for the stackblitz demo. It's still in NG5 I know... Waiting on them to upgrade.

I'll try to put some time in this weekend for both issues. If you have a small example you want to either stick on stackblitz or similar I can help from there or copy past your Ng cli output for ng -v here. Ta

On Sat, 1 Dec 2018, 08:26 Lars <notifications@github.com wrote:

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

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/KevCJones/ngx-simple-modal/issues/50, or mute the thread https://github.com/notifications/unsubscribe-auth/AAqe8C_1xF51f97uneN-JzDP951oK_DKks5u0j0jgaJpZM4Y8yaH .

Tahiche commented 5 years ago

I think i might have encountered a similar issue. Only in AOT compiling. I get a "can´t read property 'split' of undefined", when its trying to split 'wrapperclass' but its undefined. It seems like "defaultSimpleModalOptions" is not being set under AOT. In simple-modal-holder-component: _component.options = options = Object.assign({}, this.defaultSimpleModalOptions, options);

I assign global options in providers:

{
      provide: DefaultSimpleModalOptionConfig,
      useValue: {...defaultSimpleModalOptions, ...defaultMyCustomModalOptions}
    } 

It´s fine with --aot=false, 'this.defaultSimpleModalOptions' is merged correctly with instance options.

no-aot-ngx

But with --aot compiling defaultSimpleModalOptions seems to be empty.

aot-ngx1

aot-ngx2

I find AOT related issues really hard to pin. Errors are cryptic or general and i can´t seem to find a good way to debug. Functions in decorators that don´t work, private variables that work fine in other scenarios stop being available... nightmare.

BTW, here´s my ng version in case (using ngx-simple-modal v 1.3.13) :

Angular CLI: 7.3.4
Node: 8.12.0
OS: win32 x64
Angular: 7.2.7
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.13.4
@angular-devkit/build-angular      0.13.0
@angular-devkit/build-ng-packagr   0.12.4
@angular-devkit/build-optimizer    0.13.0
@angular-devkit/build-webpack      0.13.0
@angular-devkit/core               7.3.4
@angular-devkit/schematics         7.3.4
@angular/cdk                       7.3.3
@angular/cli                       7.3.4
@ngtools/json-schema               1.1.0
@ngtools/webpack                   7.3.0
@schematics/angular                7.3.4
@schematics/update                 0.13.4
ng-packagr                         4.4.5
rxjs                               6.4.0
typescript                         3.1.1
webpack                            4.29.0
Tahiche commented 5 years ago

Update: It seems like setting the default options via "forRoot" is working fine in AOT (vs providers:[provide: DefaultSimpleModalOptionConfig] which is empty in AOT).

My custom-modals.module shared/utility module which initiates SimpleModal:

@NgModule({
  imports: [
    CommonModule,
    SimpleModalModule.forRoot({container: 'modal-container'},{...defaultSimpleModalOptions, ...defaultMyCustomModalOptions})
  ],
  exports: [... ],
  providers: [
    {
      provide: DefaultSimpleModalOptionConfig,
      useValue: {...defaultSimpleModalOptions, ...defaultMyCustomModalOptions}
    }
  ],

Currently it´s redundant as " provide: DefaultSimpleModalOptionConfig" and forRoot() are doing the same. As I said (te least in my case) only forRoot() seems to work under AOT.

kevcjones-archived commented 5 years ago

Thanks for the info and feeding back your findings. I only use the forRoot approach currently in my NG7 project, explains why I haven't hit this yet.

While I'm a little busy professionally right now , I am aiming to get some time to look into things. Feel free to PR a solution if you find it.

Contributors welcome

On Fri, 8 Mar 2019, 10:44 tahiche, notifications@github.com wrote:

Update: It seems like setting the default options via "forRoot" is working fine in AOT (vs providers:[provide: DefaultSimpleModalOptionConfig] which is empty in AOT).

My custom-modals.module shared/utility module which initiates SimpleModal:

@NgModule({

imports: [

CommonModule,

SimpleModalModule.forRoot({container: 'modal-container'},{...defaultSimpleModalOptions, ...defaultMyCustomModalOptions})

],

exports: [... ],

providers: [

{

  provide: DefaultSimpleModalOptionConfig,

  useValue: {...defaultSimpleModalOptions, ...defaultMyCustomModalOptions}

}

],

Currently it´s redundant as " provide: DefaultSimpleModalOptionConfig" and forRoot() are doing the same. As I said (te least in my case) only forRoot() seems to work under AOT.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/KevCJones/ngx-simple-modal/issues/50#issuecomment-470885822, or mute the thread https://github.com/notifications/unsubscribe-auth/AAqe8MB5Lf53oFTMRRH3fM3iTL9jqYjoks5vUj75gaJpZM4Y8yaH .