GithubHelp home page GithubHelp logo

maximelafarie / ngx-smart-modal Goto Github PK

View Code? Open in Web Editor NEW
320.0 11.0 85.0 7.25 MB

Modal/Dialog component crafted for Angular (Ivy-compatible)

Home Page: https://maximelafarie.com/ngx-smart-modal/

License: MIT License

TypeScript 93.07% JavaScript 2.08% SCSS 4.85%
angular npm-module modal-dialogs modal npm npm-package dialog angular-cli yarn library

ngx-smart-modal's Introduction

ngx-smart-modal

Join the chat at https://gitter.im/ngx-smart-modal/Lobby ci npm version npm downloads codecov

ngx-smart-modal is a lightweight and very complete Angular library for managing modals inside any Angular project.

No external library, pure Angular! 🤘

To avoid having to download a CSS library when using this package, simply use our built-in SCSS/CSS file with custom animations and overloadable variables. So you don't have to use a CSS library you don't want! What's more, it doesn't use jQuery either!

CSS-framework-agnostic

Because we want to be as neutral as we can, we made it very flexible for you to style it with any CSS framework. So if your project uses a framework which is shipped with some modal styles, you simply have to pick up its class names and set the main class in the [customClass]="'modal'" (e.g.: bootstrap). And the rest of the modal DOM elements has just to be set into the ngx-smart-modal component (e.g.: modal-dialog, modal-content, modal-header, etc.).

Features

  • Handle large quantity of modals anywhere in your app
  • Customize the style of your modals through custom CSS classes and SCSS variables!
  • No external CSS library is used so you can easily override the modals default style
  • Pass data to any modal and retrieve it very simply in the modal view (or anywhere else)
  • Events on open, close, dismiss, escape and more for each modal
  • Manage all your modal stack and data with very fast methods
  • Smart z-index computation (no ugly glitches or problems with a modal inside another)
  • A modal in a modal in a modal in a modal... I guess you got it!
  • AoT compilation support

How it works

Basically, imagine that the component is based on a service that stores any modals you create in order to let you pick them up and manage them anywhere in your app at any time. sequence diagram

Browsers Support

Chrome Firefox Edge Safari Opera
> 75 > 60 > 17 > 5.1 > 60

Based on browserl.ist

Installation

npm i ngx-smart-modal --save

Which version should I use?

If your project uses a version of Angular lower than 14 (or non-Ivy), use version <=7.4.1. Otherwise, use the latest version >=14.x.

How to use

Import the module

Add NgxSmartModalModule (with .forRoot() or .forChild() depending if the module which you import the library into is the main module of your project or a nested module) and NgxSmartModalService to your project NgModule

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { NgxSmartModalModule } from 'ngx-smart-modal';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    NgxSmartModalModule.forRoot()
  ],
  providers: [
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

Import the styles

And import ngx-smart-modal.scss or ngx-smart-modal.css in a global style file (e.g. styles.scss or styles.css in classic Angular projects or any other scss/css file it imports). Example with styles.scss:

/* You can add global styles to this file, and also import other style files */
@import "~ngx-smart-modal/styles/ngx-smart-modal"

Manipulate modals

from the template

You can use modals directly in your component's template like this:

<ngx-smart-modal #myModal identifier="myModal">
  <h1>Title</h1>
  <p>Some stuff...</p>

  <button (click)="myModal.close()">Close</button>
</ngx-smart-modal>

At this point, the modal instance is stored in the NgxSmartModalService. You can do absolutely what you want with it, anywhere in your app. For example, from a component :

import { Component } from '@angular/core';
import { NgxSmartModalService } from 'ngx-smart-modal';

@Component({
  // ...
})
export class AppComponent {
  constructor(public ngxSmartModalService: NgxSmartModalService) {
  }
}

Then in the AppComponent view you can open any modal with no need to be in the same view:

<button (click)="ngxSmartModalService.getModal('myModal').open()">Open myModal</button>

with class reference (since 7.2.0)

import { Component } from '@angular/core';

import { MyComponent } from 'xxxx';

import { NgxSmartModalService } from 'ngx-smart-modal';

@Component({
  // ...
})
export class AppComponent {
  // If Angular < 8
  // @ViewChild(TemplateRef) tpl: TemplateRef<any>;

  // If Angular >= 8
  @ViewChild(TemplateRef, { static: false }) tpl: TemplateRef<any>;

  constructor(private ngxSmartModalService: NgxSmartModalService, private vcr: ViewContainerRef) {
    // simple text content
    this.ngxSmartModalService.create('myModal1', 'content', vcr).open();

    // component
    this.ngxSmartModalService.create('myModal2', MyComponent, vcr).open();

    // or templateRef
    this.ngxSmartModalService.create('myModal3', this.tpl, vcr).open();
  }
}

Manipulate data

You can associate data with any created modal. To do that, use the setModalData() from the NgxSmartModalService:

import { AfterViewInit, Component } from '@angular/core';
import { NgxSmartModalService } from 'ngx-smart-modal';

@Component({
  // ...
})
export class AppComponent implements AfterViewInit {
  constructor(public ngxSmartModalService: NgxSmartModalService) {
  }

  ngAfterViewInit() {
    const obj: Object = {
      prop1: 'test',
      prop2: true,
      prop3: [{a: 'a', b: 'b'}, {c: 'c', d: 'd'}],
      prop4: 327652175423
    };

    this.ngxSmartModalService.setModalData(obj, 'myModal');
  }
}

After that, you can retrieve the modal data directly from the view with the getData() modal property. To avoid any errors with unavailable data, you can use the hasData() modal property (It's dynamic. If data comes after a certain time its value will automatically change to true):

<ngx-smart-modal #myModal identifier="myModal">
  <div *ngIf="myModal.hasData()">
    <pre>{{ myModal.getData() | json }}</pre>
  </div>

  <button (click)="myModal.close()">Close</button>
</ngx-smart-modal>

Handle events

ngx-smart-modal comes with several built-in events:

  • onOpen: modal is opening
  • onOpenFinished: modal has been opened
  • onClose: modal is closing
  • onCloseFinished: modal has been closed
  • onDismiss: modal is closing by clicking on its backdrop
  • onDismissFinished: modal has been closed by clicking on its backdrop
  • onEscape: modal has been closed by escape key
  • onAnyCloseEvent: modal is closing whatever the kind of event (close / escape / dismiss)
  • onAnyCloseEventFinished: modal has been closed whatever the kind of event (close / escape / dismiss)
  • visibleChange: modal visibility has changed (regardless of the modal visibility state)
  • onDataAdded: data were added to the modal (using setData())
  • onDataRemoved data were removed from the modal (using removeData())

You can handle events directly from the view...

<ngx-smart-modal #myModal identifier="myModal" (onOpen)="log('Modal opened!')" (onClose)="log('Modal closed!')" (onDismiss)="log('Modal dismissed!')">
  <h1>Title</h1>
  <p>Some stuff...</p>

  <button (click)="myModal.close()">Close</button>
</ngx-smart-modal>

...and execute component's functions:

@Component({
  // ...
})
export class AppComponent {
  constructor() {
  }

  public log(msg: string) {
    console.log(msg);
  }
}

Or you can declare modal in any template (e.g.: the Rickroll demo modal)...

<ngx-smart-modal #videoModal identifier="videoModal" customClass="medium-modal">
  <h1>Hey, I Rickrolled You!</h1>
  <iframe #rickroll width="1280" height="720"
          src="https://www.youtube.com/embed/dQw4w9WgXcQ?rel=0&autoplay=1&controls=0&showinfo=0&ecver=1&enablejsapi=1"
          frameborder="0" allowfullscreen></iframe>

  <button class="button -dark" (click)="videoModal.close()">Close</button>
</ngx-smart-modal>

... and listen to its events from any component:

export class AppComponent implements AfterViewInit {
  // ...
  constructor(public ngxSmartModalService: NgxSmartModalService) {
  }

  ngAfterViewInit() {
    this.ngxSmartModalService.getModal('videoModal').onOpen.subscribe((modal: NgxSmartModalComponent) => {
      console.log('Rickroll modal opened!', modal);
    });
  }
}

Parameters (INgxSmartModalOptions)

ngx-smart-modal comes with some parameters / options in order to make it fit your needs. The following parameters / options needs to be used like this: <ngx-smart-modal [parameter-or-option-name]="value"></ngx-smart-modal>

The below documentation will use the following pattern:

parameter/option name (type) | default value | required? ― description

  • closable (boolean) | trueShow / hide the cross icon at the top right corner of the modal

  • escapable (boolean) | trueEnable / disable the modal for listening to the escape keypress event (if pressed and this option is set to true, it will close the current opened modal or the latest opened if you have several modals opened at the same time)

  • dismissable (boolean) | trueEnable / disable the modal backdrop for listening to the click event (if backdrop is clicked and this option is set to true, it will close the current opened modal or the latest opened if you have several modals opened at the same time)

  • identifier (string) | undefined | REQUIREDThe identifiant of the modal instance. Retrieve a modal easily by its identifier

  • force (boolean) | true ― If true and if you declare another modal instance with the same identifier that another, the service will override it by the new you declare in the modal stack

  • customClass (string) | 'nsm-dialog-animation-fade'All the additionnal classes you want to add to the modal (e.g.: any bootstrap modal class). You can add several classes by giving a string with space-separated class names

  • backdrop (boolean) | trueEnable / disable the backdrop of a modal. Tip: when you want to encapsulate several modals, set this options at true for the parent modal and false for the others

  • hideDelay (number) | 500Opening / closing class delay in milliseconds

  • autostart (boolean) | falseDefine if the modal is showing up automatically when loaded or not

  • target (string) | undefinedDisplays the modal relatively to the targeted element

API

ngx-smart-modal also comes with the NgxSmartModalService that you can use in any component like this:

import { Component } from '@angular/core';
import { NgxSmartModalService } from 'ngx-smart-modal';

@Component({
  // ...
})
export class AppComponent {
  constructor(public ngxSmartModalService: NgxSmartModalService) {
  }
}

List of available methods:

  • create(id: string, content: string or Component or TemplateRef, vcr: a ViewContainerRef reference, options: INgxSmartModalOptions): create a new modal and return the modal instance
  • addModal(modalInstance: ModalInstance, force?: boolean): add a new modal instance
  • getModal(id: string): retrieve a modal instance by its identifier
  • get(id: string): retrieve a modal instance by its identifier (alias of getModal)
  • open(id: string, force?: boolean): open a given modal
  • close(id: string): close a given modal
  • toggle(id: string, force?: boolean): toggle a given modal
  • getModalStack(): retrieve all the created modals
  • getOpenedModals(): retrieve all the opened modals
  • getHigherIndex(): get the higher z-index value between all the modal instances
  • getModalStackCount(): it gives the number of modal instances
  • removeModal(id: string): remove a modal instance from the modal stack
  • setModalData(data: any, id: string, force?: boolean): associate data to an identified modal
  • getModalData(id: string): retrieve modal data by its identifier
  • resetModalData(id: string): reset the data attached to a given modal
  • closeLatestModal(): Close the latest opened modal if it has been declared as escapable

Style & customization

ngx-smart-modal provides built-in SCSS variables that you can override easily like it (assuming you imported ngx-smart-modal.scss as explained above):

/* You can add global styles to this file, and also import other style files */
/* NgxSmartModal variables override */
$color-overlay: rgba(0, 0, 0, .7);
$dialog-position-top: 20%;

@import "~ngx-smart-modal/ngx-smart-modal";
// ...

Note that variables needs to be overridden before @import!

Available SCSS variables

The below documentation will use the following pattern:

parameter/option name (type) | default value | description

  • $color-overlay (hex / rgb / rgba) | rgba(0, 0, 0, .5)Modifies the modals overlay background color

  • $dialog-position-top (px / %) | 1.75remDefines the position of the modal from the top of the screen

  • $dialog-position-right (px / %) | 1.75remDefines the position of the modal from the right of the screen

  • $dialog-position-bottom (px / %) | 1.75remDefines the position of the modal from the bottom of the screen

  • $dialog-position-left (px / %) | 1.75remDefines the position of the modal from the left of the screen

  • $transition-duration (duration) | 500msDefines the transition effect duration. Keep in mind you also need to set the same time (in ms) in the hideDelay modal option (see below)

  • $transition-timing-function (transition-timing-function Property) | ease-in-outSpecifies the speed curve of the transition effect (available speed curves here)

Built-in effects

ngx-smart-modal can understand several built-in classes to open differently with a sexy effect:

To change this effect, you can use the customClass option (see below) but you also can define your own class names with dedicated effect and pass them to customClass!

  • ``: no class. The modal will show without any transition effect
  • .nsm-dialog-animation-fade: default modal effect with a simple fade effect
  • .nsm-dialog-animation-ltr: the modal comes with a left-to-right effect
  • .nsm-dialog-animation-rtl: the modal comes with a right-to-left effect
  • .nsm-dialog-animation-ttb: the modal comes with a top-to-bottom effect
  • .nsm-dialog-animation-btt: the modal comes with a bottom-to-top effect
  • .nsm-centered: the modal is centered vertically

Contributors

Many thanks to our awesome contributors! ♥️ Still not on the list? Let's contribute!

ngx-smart-modal's People

Contributors

antler-24rus avatar antonpolyakin avatar auxx avatar be-ndee avatar borbaguskada avatar codycahoon avatar gaetanmarsault avatar gavmck avatar greenkeeper[bot] avatar jwmcgettigan avatar khylias avatar louisaugry avatar marco10024 avatar marcreichel avatar maximelafarie avatar mcsky avatar mduran-nerd avatar melicerte avatar nek- avatar neromaycry avatar pcmill avatar thomascsd avatar yosbelms 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  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  avatar  avatar

ngx-smart-modal's Issues

Prevent redundant keyup-listeners from being registered

I'm submitting a feature request

[ ] bug report
[ x ] feature request
[ ] support request

Current behavior
Currently, instantiating any ngx-smart-modal register a keyup listener on the document, this causes exponential performance issues when a modal appears in a looped component.

Yes, I am aware the solution for this is to treat a modal like a singleton and ensure it is only declared once but that is not the point here.

Expected behavior
A listener should only be created when the corresponding config parameter requires it to be so.
e.g. a ngx-smart-modal where escapable is false should not register a keyup listener on the document.

Reproduction of the problem

  • Two modals appear in my list of 139 items, 7 appear outside of the list:
    image

  • After removing both modals:
    image

What is the motivation / use case for changing the behavior?
Behavior that is configured to be disabled should be completely disabled.

Please tell us about your environment:
macOS High Sierra 10.13.6

  • Smart Modal version: 6.0.4

  • Angular version: 5.2.11

  • Browser: all

  • Language: Typescript

visible field doesnt work

I'm submitting a ... (check one with "x")

[ x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior
visible attr is not taken into account
Expected behavior
visible attr should be taken into account

Reproduction of the problem
Add [visible]="true" and see if it shows up

What is the motivation / use case for changing the behavior?
I dont know

Please tell us about your environment:
not important

  • Smart Modal version: 0.8.x
    latest

  • Angular version: 2.0.x
    ang 5

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
    chrome

  • Language: [all | TypeScript X.X | ES6/7 | ES5]

cannot set the custom style for the modal

I'm submitting a ... (check one with "x")

[ ] bug report 
[ ] feature request
[x ] support request

Hi and thank you for your useful component,
My problem is that I need to set the modal width to say 90% but it seems that the styles are not applied to the element. In fact if I set this style directly on the element (inspecting it in Chrome), it works, but not when I just use the styles in the code.

  <ngx-smart-modal #createModal [identifier]="'createModal'" [customClass]="'wide-modal'">
    <app-create-role *ngIf="showCreate" (done)="createDone()"></app-create-role>
  </ngx-smart-modal>

style:

.wide-modal {
  min-width: 900px;
  background-color: blue; // Just to confirm that no style is being applied, irrespective of the parent, etc.
  
}

Modal cannot be opened on ngOnInit/ngAfterViewInit

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior

Currently the modal is not shown when trying to open it on ngOnInit/ngAfterViewInit of app.component because it is not registered yet. It is only working with a setTimeout().

Expected behavior

I would expect that the modal can be opened without a setTimeout().

Reproduction of the problem

What is the motivation / use case for changing the behavior?

I would like to show a modal automatically after the login without user interaction.

Please tell us about your environment:

  • Smart Modal version: 2.0.3
  • Angular version: 5.2.x
  • Browser: [all]
  • Language: [all]

inconsistent vertical location

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x ] feature request
https://github.com/biig-io/ngx-smart-modal/issues/new
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior
My current table is quite long and when I want to display modal, I have to set $dialog-position-top: 70%; which is weird since 70% is fine.

But then, when my table list is small, I can't see it anymore unless I reset the top position to much less value.

Expected behavior
I was hoping the top position simply calculates from the actual screen, regardless of page content. So 50% would place it at center, 0% at the top etc, 20px. Regardless, I thought it calculates from the screen, instead of the content which I have no control over at all.

In fact, adding position:fixed to the core scss file does the trick.

Reproduction of the problem

What is the motivation / use case for changing the behavior?

It would be nice and easier to either have percentage or pixel or even pre-defined settings like 'center' would mean center of the screen regardless of the content on display

Please tell us about your environment:

Windows 7. Webpack. NPM. Apache

  • Smart Modal version: 0.8.x
  • Angular version: 2.0.x

5

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Chrome and Firefox

  • Language: [all | TypeScript X.X | ES6/7 | ES5]
    ES6

NPM documentation out of date

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior

The installation instruction on NPM under the header appears to be out of date. The line for importing the SCSS is: @import "ngx-smart-modal/ngx-smart-modal";. For me this did not work and the line appears to be missing a tilde.

Expected behavior

When looking at the documentation on Github that line on how to importing SCSS is @import "~ngx-smart-modal/ngx-smart-modal";. Here a tilde appears in the path, and this import path works for me.

Suggested solution

Update the NPM page https://www.npmjs.com/package/ngx-smart-modal to have the correct import path for scss.

getModalData method returns undefined

I'm submitting a ...

[ x ] bug report 
[ ] feature request
[ ] support request 

Current behavior
I am setting up some data with setModalData method. When I try to get data by using getModalData method I always get value undefined.

Expected behavior
It should return data which was set by setModalData method

Passing an number equal to 0 on setModalData()

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior

I want to pass on setModalData() the index of my current element. In case, that is equal to 0 (first element of my array), hasData() return false and didn't show up the *ngIf content.

Expected behavior

hasData() make difference between no content and content equal to 0.

What is the motivation / use case for changing the behavior?

Personnal project.

Please tell us about your environment:

  • Smart Modal version:

"ngx-smart-modal": "^5.0.0"

  • Angular version:

"@angular/core": "^5.2.9"

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Language: [all | TypeScript X.X | ES6/7 | ES5]

hasData don't return true just after calling setData

[ x ] bug report 
[ ] feature request
[ ] support request

Current behavior
When you set data to your modal and call hasData at the next line you'll get a false.
It isn't a really common case but may lead to confusion.

Expected behavior

When some data is set on the modal the function hasData should return true

Reproduction of the problem

const modal = modalService.getModal('myModal');
modal.hasData() // return false, it's ok
modal.setData('foo') 
modal.hasData() // Return false, wuutttt
setTimeout(() => console.log(modal.hasData()), 0); // Print yes
  • Browser: [all ]

Issue using angular 4

Hello i using you very good component but have a question when run de command npm start i get this error

ERROR in Error: Metadata version mismatch for module C:/wamp64/www/FMA/app/node_modules/ngx-smart-modal/ngx-smart-modal.d.ts, found version 4, expected 3, resolving symbol AppModule in C:/wamp64/www/FMA/app/src/app/app.module.ts, resolving symbol AppModule in C:/wamp64/www/FMA/app/src/app/app.module.ts, resolving symbol AppModule in C:/wamp64/www/FMA/app/src/app/app.module.ts
    at Error (native)
    at syntaxError (C:\wamp64\www\FMA\app\node_modules\@angular\compiler\bundles\compiler.umd.js:1729:34)
    at simplifyInContext (C:\wamp64\www\FMA\app\node_modules\@angular\compiler\bundles\compiler.umd.js:25118:23)
    at StaticReflector.simplify (C:\wamp64\www\FMA\app\node_modules\@angular\compiler\bundles\compiler.umd.js:25130:13)
    at StaticReflector.annotations (C:\wamp64\www\FMA\app\node_modules\@angular\compiler\bundles\compiler.umd.js:24558:41)
    at _getNgModuleMetadata (C:\wamp64\www\FMA\app\node_modules\@angular\compiler-cli\src\ngtools_impl.js:138:31)
    at _extractLazyRoutesFromStaticModule (C:\wamp64\www\FMA\app\node_modules\@angular\compiler-cli\src\ngtools_impl.js:109:26)
    at Object.listLazyRoutesOfModule (C:\wamp64\www\FMA\app\node_modules\@angular\compiler-cli\src\ngtools_impl.js:53:22)
    at Function.NgTools_InternalApi_NG_2.listLazyRoutes (C:\wamp64\www\FMA\app\node_modules\@angular\compiler-cli\src\ngtools_api.js:91:39)
    at AotPlugin._getLazyRoutesFromNgtools (C:\wamp64\www\FMA\app\node_modules\@ngtools\webpack\src\plugin.js:207:44)
    at _donePromise.Promise.resolve.then.then.then.then.then (C:\wamp64\www\FMA\app\node_modules\@ngtools\webpack\src\plugin.js:443:24)
    at process._tickCallback (internal/process/next_tick.js:109:7)

But if i remove the dependeci injeccion of your module before npm start, this complile ok, if i put the dependencies of your module after to compile (npm start) all is ok. I have no idea what happend

This is my package.json

  "name": "fma",
  "version": "3.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@amcharts/amcharts3-angular": "^1.5.0",
    "@angular/animations": "^4.4.4",
    "@angular/cdk": "^2.0.0-beta.11",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/material": "^2.0.0-beta.11",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/router": "^4.2.4",
    "angular-datatables": "^4.4.0",
    "core-js": "^2.4.1",
    "datatables.net": "^1.10.16",
    "datatables.net-dt": "^1.10.16",
    "hammerjs": "^2.0.8",
    "jquery": "^3.2.1",
    "ngx-smart-modal": "^5.0.0",
    "ngx-toastr": "^6.4.0",
    "rxjs": "^5.4.2",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "1.4.3",
    "@angular/compiler-cli": "^4.2.4",
    "@angular/language-service": "^4.2.4",
    "@types/datatables.net": "^1.10.6",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/jquery": "^3.2.13",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.1.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.3.2",
    "typescript": "~2.3.3"
  }
}

Best regards

Request component input to assign modal relative parent

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior

I'm using a left sidebar menu in my angular app. The ngx-smart-modal component is instantiated in my main content area which is on the right side of the screen because the sidebar is on the left side. The problem is when I open the modal, it center itself relative to the main content screen which I completely understand why.

Expected behavior

I would love a feature where I can assign where the modal is relative to (e.g "body") so it can center itself according to my needs.

Reproduction of the problem

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • Smart Modal version: 6.0.0
  • Angular version: 5.0.x
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Language: [all | TypeScript X.X | ES6/7 | ES5]

ngx-smart-modal parameters are not working in angular5

I am using 'ngx-smart-modal' version of 3.1.0 in my angular5 app with the help of this link .When I given the default parameters mentioned in the official tutorial it's not working.

`<ngx-smart-modal #myModal identifier="myModal" dismissable="false">

hello

`

in the above code I trying to give the dismissable parameter as false for preventing the closing of modal when clicking on backdrop,but it's not working.How can I pass these parameters in ngx-smart-modal ?

Unable to use custom directives

Expected Behavior

Custom attribute directive to work as intended

Current Behavior

Directive not working in any way, Not being triggered either.

Steps to Reproduce

  1. Create a custom directive (E.g.: Change background color on input)
  2. Put inside <ngx-smart-modal><ngx-smart-modal/>
  3. Open Modal

Code example

component.template.html

<ngx-smart-modal #userFormModal [identifier]="'user-form-modal'" [backdrop]="false"
                  [customClass]="'form-modal'"
                  [closable]="false">
  <input type="text" appHighlight />
</ngx-smart-modal>

Opening modal with

constructor(public modalService: NgxSmartModalService){}

openModal(): void {
  this.modalService.getModal('user-form-modal').open();
}

highlight.directive.ts

import { AfterViewInit, Directive, ElementRef, OnInit } from '@angular/core';

@Directive({
  selector: '[appHighlight]'
})
export class HighlightDirective implements {
  constructor(private el: ElementRef) {
    el.nativeElement.style.backgroundColor = 'yellow';
  }
}

Make the modal scrollable

If the content of the modal is big and its height is greater than the height of the screen / browser, the modal extends the main height, event if the body's height is limited and/or defined e.g.:

body { height: 100%; }

At the beginning the modal has a normal behavior:
image

But at scroll time, the whole page is scrolling, not only the modal (and this is what we want !):
image

How to call any component method from ngx-smart-modal view?

Hi @maximelafarie, below is not the actual code but sample code to show what I am trying to achieve. Basically, I want to call child component method from "ngx-smart-modal" view which is in the my-app component.
(click)="child.doSomething()"

I give child component an Identifier name "#child" and trying to call its method using "child.doSomething()". But it is not working and throwing an error something like that "Cannot read doSomething of undefined"

Maybe I am doing it in a wrong way so I want to know how to call component methods from "ngx-smart-modal" no matter where this modal is present in my-app application?

import {Component} from '@angular/core';
import {NgxSmartModalService} from 'ngx-smart-modal';

@Component({
  selector: 'my-app',
  templateUrl: '<child-cmp #child></child-cmp>
                <ngx-smart-modal #myModal1 [identifier]="'myModal1'"> 
                    <button (click)="child.doSomething()">submit</button>
                </ngx-smart-modal>'
})

export class AppComponent {
  constructor(public ngxSmartModalService: NgxSmartModalService) {
  }
}


@Component({
  selector: 'child-cmp',
  template: '<p>child</p>'
})
class ChildCmp {
  doSomething() {}
}

Refactor library styles

Given that we impose the way modals are appearing (only one animation with @angular/animations), it could be nice to remove them and include .scss and .css dedicated styles.

Then, programmers could import it to their project or not if they want to make the lib styles theirselves.

A dedicated UI/UX developer will be assigned to this issue.

Angular 6 plans?

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[ X ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior
Ngx-smart-modal is on Angular 5 at the moment and may be incompatible with Angular 6 apps.

Expected behavior
Update the library to support Angular 6

Reproduction of the problem
I don't have any problems at this moment.

What is the motivation / use case for changing the behavior?
With the new update of Angular, they have introduced new RxJS features and some minor features that boosts the performance of your app.

Please tell us about your environment:

  • Angular version: 5.1.x
  • Browser: All
  • Language: TypeScript 2.7

Error on open : BrowserAnimationModule

I'm submitting a ...

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior
I've got the NPM Warning with web-animation-js, I add it. But it keep an error on modal opening.

NgxSmartModalComponent.html:64 ERROR Error: Found the synthetic property @dialog. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application.

Expected behavior
Integrate BrowserAnimationModule on NgxSmartModalComponent directly.

Reproduction of the problem
Install module and try.

  • NgxSmartModal version: 3.0.0

  • Angular version: 4.4.6

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

  • Language: [all | TypeScript X.X | ES6/7 | ES5]

Make some shortcuts to open/close a modal with the NgxSmartModalService

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[X] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior

Actually, to open or close a modal using the service, we need to do this way:

<button (click)="ngxSmartModalService.getModal('myModal').open()">Open</button>
<button (click)="ngxSmartModalService.getModal('myModal').close()">Close</button>

Expected behavior

Open/close a modal this way:

<button (click)="ngxSmartModalService.open('myModal')">Open</button>
<button (click)="ngxSmartModalService.close('myModal')">Close</button>

What is the motivation / use case for changing the behavior?

It could be less painful (in coding terms) to open/close a modal using the NgxSmartModalService.
In addition, it won't require the entire modal but directly call its open/close methods.

  • Smart Modal version: ALL
  • Angular version: ALL
  • Browser: ALL

Opening same modal in multiple components

Hello,

What i am trying to do is open a modal that has been created in a componentA, in another component called componentB, in order to use the same modal in multiple Components on click events, but im getting this error:

_ERROR TypeError: Cannot read property 'modal' of undefined
    at NgxSmartModalService.getModal (ngx-smart-modal.js:64)
    at Object.eval [as handleEvent] (componentB.html:4)
    at handleEvent (core.js:13547)
    at callWithDebugContext (core.js:15056)
    at Object.debugHandleEvent [as handleEvent] (core.js:14643)
    at dispatchEvent (core.js:9962)
    at eval (core.js:10587)
    at HTMLButtonElement.eval (platform-browser.js:2628)
    at ZoneDelegate.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.js:4740)_

Am I doing something wrong? or how can I acomplish this task?

Here is the code:
ComponentA

<ngx-smart-modal #myModal identifier="myModal" [closable]="true" [escapable]="true" [dismissable]="true">
  <h1>Title</h1>
  <p>Some stuff...</p>

  <button class="btn btn-primary" (click)="myModal .close()">Close</button>
</ngx-smart-modal>

<button class="btn btn-primary" (click)="ngxSmartModalService.getModal('myModal').open()">Open myModa</button>

import { Component, OnInit, AfterViewInit } from '@angular/core';
import { NgxSmartModalService } from 'ngx-smart-modal';


@Component({
  selector: 'app-componentA',
  templateUrl: './componentA.component.html',
  styleUrls: ['./componentA.component.css']
})
export class ComponentA implements AfterViewInit {

  constructor(public ngxSmartModalService: NgxSmartModalService) { }
  ngAfterViewInit() {
    const obj: Object = {
      prop1: 'test',
      prop2: true,
      prop3: [{ a: 'a', b: 'b' }, { c: 'c', d: 'd' }],
      prop4: 327652175423
    };

    this.ngxSmartModalService.setModalData(obj, 'myModal');
  }
}

ComponentB

<button class="btn btn-primary" (click)="ngxSmartModalService.getModal('myModal').open()">Open myModa</button>

import { Component, OnInit, AfterViewInit } from '@angular/core';
import { NgxSmartModalService } from 'ngx-smart-modal';

@Component({
  selector: 'app-componentB',
  templateUrl: './componentB.component.html',
  styleUrls: ['./componentB.component.css']
})
export class ComponentB {
  constructor(public ngxSmartModalService: NgxSmartModalService) { }
}

set dialog width?

version:6.0

how to modify dialog width?
i set

.nsm-dialog {
&.nsm-dialog-open
{ width: 75% ;
}
}

in sub-Component's scss file

but its not useful

i only could set it in source file "ngx-smart-modal/ngx-smart-modal.scss"
@import "~ngx-smart-modal/ngx-smart-modal";
it's useful

but it will be Global style,i need part style

sorry my English is not good

thx for this goods

Override/disable animation

Would be nice to be able to override or at least disable the angular animation currently on the modal. The current animation isn't really working out for full-screen modals.

How to switch back modal position to absolute position from app's level instead of parent's level ?

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior
I have upgrade ngx-smart-modal from v5.x to 7.x and found that position of my modals changes how it looks from v5.x which is using layout from app's position to using layout from parent's position.

My components structure design is stacked and able to call infinite.
For example
-Staff list component
      -Show staff info
      -Show department list component
-Department list component
      -Show department info
      -Show staff list component
-App root
      -Show staff list component
so it will recursive call each other on click event.
Please take a look sample, In staff list choose 1 staff it will popup department list, Choose 1 department it will popup staff list and so on.
https://plnkr.co/l5snyhlMgsIkjODTTobt

After i changed to v7.x when using modal inside modal it will show inside main modal instead of app's position.
https://plnkr.co/WQw0fC6x5mcF7WB03lV2
Also i tried to use "target" but still not working.
https://plnkr.co/Ag5nLm

Expected behavior
Please take a look on my plnk for v5.x when using modal inside modal it will show in layout of app's position.
https://plnkr.co/l5snyhlMgsIkjODTTobt

[Feature Request] Add dismissable input for modals

[ ] bug report => search github for a similar issue or PR before submitting
[ X] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior
Currently if you click the backdrop the modal closes.

Expected behavior
If [dismissable] is false clicking the backdrop doesnt close the modal.

Reproduction of the problem
<ngx-smart-modal #myModal [identifier]="'myModal'" [dismissable]="false" [closable]="false" [escapeAble]="false">

What is the motivation / use case for changing the behavior?
I currently have an upload with file selector on a modal. If i click and select the file from the file selector it closes but if I do an additional click accidentally and it lands on the backdrop it will close the modal.

Having a dismissable false will stop the backdrop from being used as a close

Dismiss manually doesn't work

Hi, I'm using ngx-smart-modal in an Angular 6/RxJs application to display a confirm dialog. The problem is that it seems you can create just one button, the 'close' button, that triggers myModal.close().
So, I thought I could add two buttons to allow the user to confirm or cancel the modal.
CANCEL BUTTON:

<button (click)="confirmModal.dismiss()" type="button">{{confirmModal.getData().cancelBtnLabel}}</button>

CONFIRM BUTTON:

<button (click)="confirmModal.close(true)" type="button">{{confirmModal.getData().confirmBtnLabel}}</button>

And then the component where there is the button to open the modal:

openConfirmModal() {    
    const confirmModalData: Object = {
       ...
      };
      this.ngxSmartModalService.setModalData(confirmModalData, 'confirmModal');
      let confirmModalRef = this.ngxSmartModalService.getModal('confirmModal');
      confirmModalRef.onDismiss.subscribe(() => {
        ....
      });
      confirmModalRef.onClose.subscribe((test: boolean) => {
        .....
      });
      confirmModalRef.open();
}

But if I click on cancel button, I have the following error in the console:

ERROR TypeError: Cannot read property 'target' of undefined
    at NgxSmartModalComponent.push../node_modules/ngx-smart-modal/esm5/ngx-smart-modal.js.NgxSmartModalComponent.dismiss

SetModalData isn't overwritten on dynamic set

I'm submitting a ... (check one with "x")
[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior

I'll set my modal data dynamically on a click event, but data doesn't change when I'll click on an another button and keep the first data.

Expected behavior

All of my modal open with the right data.

Reproduction of the problem

You can test my behavior here : https://plnkr.co/Ov124mJajTkWxmrl8hrZ?p=preview

What is the motivation / use case for changing the behavior?

I've got dynamic data and I need to set dynamic modal data.

Please tell us about your environment:

No need for this issue.

  • Smart Modal version: 2.0.x
  • Angular version: 5.0.x
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Language: [all | TypeScript X.X | ES6/7 | ES5]

How to use multiple popups in single page on gridview

How to use Multiple popups on my index.html page. here is my code can you please help on this.

module.ts

import {Component} from '@angular/core';
import { NgxSmartModalModule, NgxSmartModalService } from 'ngx-smart-modal';

import { popupModalOne } from './popup1-modal';
import { popupModalTwo } from './popup2-modal';

@NgModule({
  declarations: [
    Appcomponent, popupModalOne, popupModalTwo
  ],
  imports: [
    FormsModule,
    BrowserModule,
    NgxPaginationModule,
    BrowserAnimationsModule,
    ModalModule.forRoot(),
    NgxSmartModalModule.forRoot()
  ],
  providers: [NgxSmartModalService],
  bootstrap: [Appcomponent] 
})

app.component.html

Here is my list of records having view/edit popups displaying...

<app-root></app-root>
<one-modal></one-modal>
<two-modal></two-modal>
 
1. <button (click)="ngxSmartModalService.getModal('popupOne').open()">Open myModal 1</button>
2. <button (click)="ngxSmartModalService.getModal('popuptwo').open()">Open myModal 2</button>

app.component.ts

import {AfterViewInit, Component} from '@angular/core';
import {NgxSmartModalService} from 'ngx-smart-modal';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'] 
}) 

export class AppComponent implements AfterViewInit {
  constructor(public ngxSmartModalService: NgxSmartModalService) {
  }
  ngAfterViewInit() {
    const pen: Object = {
      prop1: 'test',
      prop2: true,
      prop3: [{a: 'a', b: 'b'}, {c: 'c', d: 'd'}],
      prop4: 327652175423
    };
    this.ngxSmartModalService.setModalData(pen, 'popupOne');
   const book: Object = {
      prop1: 'test',
      prop2: true,
      prop3: [{a: 'a', b: 'b'}, {c: 'c', d: 'd'}],
      prop4: 327652175423
    };
     this.ngxSmartModalService.setModalData(book, 'popuptwo');
  }
}

page-two-component.html

@Component({
selector: 'one-modal',
templateUrl: './page-One-component.html'
})

<ngx-smart-modal #popupOne [identifier]="'popupOne'">
  <h1>Title 1</h1>
  <p>Hello</p>
  <button (click)="popupOne.close()">Close</button>
</ngx-smart-modal>

page-two-component.html

@Component({
selector: 'two-modal',
templateUrl: './page-two-component.html'
})

<ngx-smart-modal #popuptwo [identifier]="'popuptwo'">
  <h1>Title 2</h1>
  <p>Hello</p>
  <button (click)="popuptwo.close()">Close</button>
</ngx-smart-modal>

How to use multiple modal windows in single page

Thanks for sharing code.
In my code component.ts page i have to call 2 model popups in a single page.
I getting error when i hit button I am getting error in console saying "BodyComponent.html:49 ERROR TypeError: Cannot read property 'modal' of undefined"
here is my code:

1. <button (click)="ngxSmartModalService.getModal('myModal1').open()">Open myModal1</button>
2. <button (click)="ngxSmartModalService.getModal('myModal2').open()">Open myModal2</button>

html:

<ngx-smart-modal #myModal1 [identifier]="'myModal1'"> 
  <button (click)="myModal.close()">Close</button>
</ngx-smart-modal>

<ngx-smart-modal #myModal2 [identifier]="'myModal2'"> 
<button (click)="myModal.close()">Close</button>
</ngx-smart-modal>

In component:

ngAfterViewInit() {
    const obj: Object = {
      prop1: 'test',
      prop2: true,
      prop3: [{a: 'a', b: 'b'}, {c: 'c', d: 'd'}],
      prop4: 327652175423
    }; 
    this.ngxSmartModalService.setModalData(obj, 'myModal1');

const obj_one: Object = {
      prop1: 'test2',
      prop2:  'data' 
    }; 
    this.ngxSmartModalService.setModalData(obj_one, 'myModal2');
  }

Using in Angular 6

I'm submitting a ... (check one with "x")

[x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior
In angular6, component just opens on to the page, instead of in a modal pop-up No console errors. Close and other features all work fine.
Expected behavior

Expected to open

Reproduction of the problem

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • Smart Modal version: 0.8.x
  • Angular version: 2.0.x
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Language: [all | TypeScript X.X | ES6/7 | ES5]

Modal not totally closing

I'm submitting a ... (check one with "x")

[X] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior
As mentioned by @melicerte, when closing a modal with closeLatestModal(), the modal seems to be not totally closed and remains present in the DOM

Expected behavior
Modal should totally disappear from the DOM on method call.

  • Browser: All

Return Promise on open()

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[X ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior
The current open() method does not return any Promise<> which is awaitable.

Expected behavior
Promise which can be awaited (resolved via classical way) after the modal has been closed/dismissed. Right now there is now way for prompting the user for something and continue afterwards.

What is the motivation / use case for changing the behavior?
I want to wait for the users input within a wizard flow.

  • Smart Modal version: 6.0.0

Fade-out animation request

I'm submitting a ...

[ ] bug report => search github for a similar issue or PR before submitting
[ x ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Currently, you provide some custom classes to open modal with some animation. But when we close modal with some outer click or ESC key, it doesn't reverse the effect by which it was opened.
For example, if modal is opened from left to right, at the time of closing it should be animated from left to right movement.

What is the motivation / use case for changing the behavior?
It provides better user experience with consistency of opening and closing modal.

Singleton instance of NgxSmartModalService for entire app

I'm submitting a ...

[ ] bug report 
[ ] feature request
[ x ] support request

In my Angular-6 application, there are many lazy-loaded modules. These modules have their own modals. As you mentioned in the documentation, I have to do NgxSmartModalModule.forChild() in my child modules. I mentioned NgxSmartModalService in providers array of my AppModule. But I want a singleton instance of NgxSmartModalService for my entire app. Is it possible to do that? If yes, Can you please suggest me how to do that?

When [closeable]="true" clicking the close button causes the parent form to submit

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior
Clicking the X close button top right when [closeable]="true" causes the form on the parent page to submit. If this is implemented as a button then it needs type="button" as the default type is a submit button.

Expected behavior
The dialog should just close without submitting the parent form.

Reproduction of the problem
Invoke the dialog from a page with a form that is active. Click the X button. The parent form submits.

What is the motivation / use case for changing the behavior?
Unintended side effects,

Please tell us about your environment:
Angular 5 cli

  • Smart Modal version:
    6.0.0

  • Angular version:
    5.2.0

  • Browser:
    Chrome Version 66.0.3359.139 (Official Build) (64-bit)
    Firefox 59.0.2 64 Bit

  • Language:
    Typescript

Update license on demo page

Actually, it's written Released under the ISC license. on your demo page.
But the project is under MIT license 😉

Setting Higher Index

I'm submitting a ...

[ ] bug report
[ x ] feature request
[ ] support request

There is a method to get a higher z-index value. But there is not any method to set this higher z-index value to some modal.
What I mean is, let's assume I opened a modal named A. This modal has a button to open another modal named B. I know if I put modal selectors properly in HTML B can be opened over A.
But if I have some other requirements, I should be able to assign a higher z-index value to modal, provided one has modal-ID.

My conclusion, there should be a method something like setHigherIndex(modal-id).

Thanks.

Create a global 'onAllClosingEvent'

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[X] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior

Actually, if you want to do an action after modal closing/escape/dismiss, you need to subscribe the three events and do the same action three times.

Expected behavior

What is the motivation / use case for changing the behavior?

Avoid code duplication.

  • Smart Modal version: ALL
  • Angular version: ALL
  • Browser: [all]
  • Language: [all]

Error when performing AOT build: Property 'escapeKeyboardEvent' is private

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior

When performing an AOT build, I get the following error.

ERROR in (1,1): : Directive NgxSmartModalComponent, Property 'escapeKeyboardEvent' is private and only accessible within class 'NgxSmartModalComponent'.
ClientApp\app\public\productdetails\productdetails.component.html(56,1): : Directive NgxSmartModalComponent, Property 'escapeKeyboardEvent' is private and only accessible within class 'NgxSmartModalComponent'.

Expected behavior

I was expecting to be able to do AOT build.

Reproduction of the problem

Content of component HTML template

<!-- ... -->
<ngx-smart-modal #classicModal identifier="classicModal">
  <h1>Hey, I'm a simple modal!</h1>
  <img class="modal-image" src="http://lorempicsum.com/futurama/627/200/3" alt="Lorem picsum">
  <p>{{ "sampleText[0]" }}</p>
  <button class="button -dark" (click)="classicModal.close()">Close</button>
</ngx-smart-modal>

Content of app module

  // ...
  imports: [
    BrowserModule,
    HttpClientModule,
    FormsModule,
    ReactiveFormsModule,
    NgxSmartModalModule.forRoot(),
    // ....
  ]
  // ...

Please tell us about your environment:

  • Windows 10 Enterprise

  • Smart Modal version: 6.0.2

  • Angular version: 5.2.10
  • Browser: N/A

  • Language: TypeScript 2.5.3

BrowserModule should be removed

If I import the NgxSmartModal in my shared module i will get an error saying "BrowserModule has already been loaded. If you need access to common..."

To make it work I have to remove the BrowserModule and BrowserAnimationModule from the NgxSmartModal decorators in ngx-smart-modal.js

NgxSmartModalModule.decorators = [
{ type: NgModule, args: [{
declarations: [NgxSmartModalComponent],
exports: [NgxSmartModalComponent],
imports: [CommonModule]
},] },
];

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.