🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

a4-modal

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a4-modal

Handle modal related tasks

9.0.0
latest
npm
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

a4-modal

Angular 7 Modal

How-To

Install

npm install a4-modal

app.module.ts

  • Add ModalModule to imports of the app.module.ts.

...
import { ModalModule } from 'a4-modal';
...

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    ...,
    ModalModule,
    ...
  ],
  ...
})

app.component.ts

  • Add viewContainerRef: ViewContainerRef to the constructor of app.component.ts.
...
import { ViewContainerRef } from '@angular/core';
...

constructor(private viewContainerRef: ViewContainerRef) { }

your.component.ts

  • Add modalService: ModalService to the constructor of your component.
constructor(private modalService: ModalService) { }
  • Invoking the modal can be done by using the service as shown below.
this.modalService.open(MyModalContentComponent)
    .then(p=> console.log(p)) // the result of the modal
    .catch(p=> console.error(p)); // when route changes
  • MyModalContentComponent will be dynamically created by the modal service. You will need to add MyModalContentComponent to the entryComponents in your module.
@NgModule({
    imports: [
        ...
    ],
    declarations: [
        ...
    ],
    providers: [
        ...
    ],
    entryComponents: [
        MyModalContentComponent
    ]

my-modal.component.ts

  • The service will automatically inject the modal component into your component.
  • Add the following code to your modal component.
...
import { ModalComponent, IModal } from 'a4-modal';
...

export class MyModalComponent implements IModal {
    ...
    modal: ModalComponent;
    ...

    closeModal() {
        this.modal.close();
    }

    ...
}

Keywords

angular

FAQs

Package last updated on 08 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts