0.2.2 • Published 3 years ago

angular-modal-simple v0.2.2

Weekly downloads
4
License
ISC
Repository
github
Last release
3 years ago

Angular Modal

Provides a simple, minimal configuration modal implementation.

Installation

npm install angular-modal-simple

Version Support

Angular 10.1+

Use

Import AngularModalModule into your application:

@NgModule({
    ...
    imports: [
        AngularModalModule.forRoot()
    ]
    ...
})

Import ModalService to display ModalComponents.

@Injectable()
public class TestService {
    constructor(private modalService: ModalService) {}
    displayTest(): void {
        this.modalService.display(TestComponent);
    }
}

Configuration Options

ModalOptions configuration options include:

PropertyTypeDescriptionDefault
canClosebooleanDetermines whether the user can close the Modaltrue
dataanyData which will populate the Component's @Input() fields{}
dismissibleMaskbooleanDetermines whether clicking the Modal container mask will close the Modaltrue
styles{}Allows custom styling to be assigned to the Modal instance{}
zIndexnumberThe zIndex for the given Modal instance0

ModalService.setDefaultOptions() can be used to define the default ModalOptions for all Modal instances.

ModalService:

FunctionParametersDescription
displaycomponent: any, options: ModalOptionsDisplays the provided Component, using the provided ModalOptions (if present). Any properties that are not present in options will utilize the defaults provided in ModalService
closecomponent: anyCloses the provided Component instance
closeAll-Closes all open Modal instances
isActivecomponent: anyDetermines if the provided Component is currently open in a Modal instance
setDefaultOptionsoptions: ModalOptionsSets the default ModalOptions that will be used for each new Modal instance
setViewContainerRefviewContainerRef: ViewContainerRefSets the ViewContainerRef that new Modal instances will be injected into (by default, ModalService will utilize ApplicationRef and inject all Modal instances into the <body> element)

Example:

TestComponent:

@Component()
public class TestComponent {
    @Input() inputA: string;
    @Input() inputB: number;
}

TestService:

@Injectable()
public class TestService {
    constructor(private modalService: ModalService) {}
    displayTest(): void {
        this.modalService.display(TestComponent, {
            data: {
                inputA: 'test',
                inputB: 3
            },
            dismissableMask: false,
            styles: {
                backgroundColor: '#eee'
            }
        });
    }
}
0.1.10

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.9

3 years ago

0.2.2

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.4

3 years ago

0.1.5

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.25

3 years ago

0.0.26

3 years ago

0.0.24

3 years ago

0.0.22

3 years ago

0.0.23

3 years ago

0.0.21

3 years ago

0.0.20

3 years ago

0.0.19

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.15

3 years ago

0.0.16

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago