Modal for Angular 2
This module allows for show modal and dialog boxes.
Demo
http://crystalui.org/components/modal
Installation
Install the npm package.
npm i @crystalui/angular-modal
Import module:
import {ModalModule} from '@crystalui/angular-modal';
@NgModule({
imports: [ModalModule]
})
Usage
To open the window, import the Modal
service and call the load()
method. As a parameter, pass your component. It will be the contents of the window.
import {Modal} from '@crystalui/angular-modal';
import {MyComponent} from './my.component';
public constructor(private modal: Modal) {};
showModal() {
this.modal.load({
id: 'my-modal',
component: MyComponent
});
}
Properties
id: string = undefined
mode: "desktop" | "mobile" | "dialog" = "desktop"
data: any
width: string = "800px"
height: string = "auto"
maxWidth: string = "calc(100% - 32px)"
maxHeight: string = "calc(100% - 32px)"
overlayBackdrop: boolean = true
backdropClass: string | { [key: string]: any; }
modalClass: string | { [key: string]: any; }
Methods
name | description |
---|
load({ id: "my-modal", component: MyComponent }) | Shows the modal. |
close({ id: "my-modal" }) | Hides the modal. |
Events
Window state changes are available by subscription stateEvents.subscribe()
.
name | description |
---|
show | The event is called before the modal appears. |
shown | The event is called after the animation of the appearance of the modal. |
hide | The event is called before the modal is hidden. |
hidden | The event is called after the animation of the modal is hidden. |