npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-azh-modal

v0.0.14

Published

A simple solution for displaying modal windows in Angular.

Downloads

19

Readme

Modal for Angular

A simple solution for displaying modal windows in Angular.

Quick start

npm install ngx-azh-modal --save

Angular version

This library is built to work with Angular ^17.1.0.

Simple example

// app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgxAzhModalModule, NgxAzhModalConfigToken } from 'ngx-azh-modal';
import { AppComponent } from './app.component';
import { AppModalConfig } from './app-modal-config';
import { YourModalComponent } from './your-modal.component';

@NgModule({
    imports: [BrowserModule, NgxAzhModalModule],
    declarations: [AppComponent, YourModalComponent],
    bootstrap: [AppComponent],
    providers: [
        {
            // Global configuration for all modal windows of the application
            provide: NgxAzhModalConfigToken,
            useClass: AppModalConfig
        }
    ]
})
export class MyAppModule {
}
// app-modal-config.ts
import { Injectable } from '@angular/core';
import { NgxAzhModalOptionsInterface, NgxAzhModalSizeEnum } from 'ngx-azh-modal';

@Injectable()
export class AppModalConfig implements NgxAzhModalOptionsInterface {
    public size: NgxAzhModalSizeEnum = NgxAzhModalSizeEnum.LARGE;
    public dontShowAgainId: string | undefined = undefined;
    public notClosed: boolean = false;
    public closeWhileNavigating: boolean = true;
}
// your-modal.component.ts
import { Component } from '@angular/core';
import { NgxAzhModalComponentInterface, NgxAzhModalResultSubject } from 'ngx-azh-modal';

@Component({
    selector: 'app-your-modal',
    template: `<!-- Template of you modal component -->`
})
export class YourModalComponent
    implements NgxAzhModalComponentInterface</* interface link */> {
    public result: NgxAzhModalResultSubject</* interface link */> = new NgxAzhModalResultSubject</* interface link */>();
    
    public onCancel(): void {
        this.result.cancel();
    }
    
    public onConfirm(): void {
        this.result.confirm( /* you data to transfer */ );
    }
}
// app.component.ts
import { Component } from '@angular/core';
import { NgxAzhModalService } from 'ngx-azh-modal';
import { YourModalComponent } from './your-modal.component';

@Component({
    selector: 'app-root',
    template: `
    <!-- IMPORTANT: place this tag in your bootstrap component! -->
    <ngx-azh-modal-placement></ngx-azh-modal-placement>`
})
export class AppComponent {
    
    constructor(private modalService: NgxAzhModalService) {
    }
    
    /**
     *
     */
    public createModal(): void {
        const cmp = this.modalService.open<YourModalComponent>(YourModalComponent);
        
        cmp.instance.result.subscribe((result) => {
            /* do something */
        });
    }
}

API

Inject tag

Inject the <ngx-azh-modal-placement></ngx-azh-modal-placement> tag into your autoload component. Otherwise, the library will not be able to show the modal!

<!-- YOUR HTML -->

<ngx-azh-modal-placement></ngx-azh-modal-placement>

<!-- YOUR HTML -->

Methods and properties:

create(component, options): ComponentRef <T> | null - Create modal.

Important: null may be returned if the user previously selected “do not show again”.

  • component [Type<T>] - required Link to modal window.
  • options [NgxAzhModalOptionsInterface] Modal options.

clear(): void - Clear all modal windows.

size: number - Returns the number of open modals.

Interface: NgxAzhModalOptionsInterface

  • size [NgxAzhModalSizeEnum] - Window dimensions. undefined by default.
  • dontShowAgainId [string] - Window ID if you want to use "don't show anymore". undefined by default.
  • notClosed [boolean] - True if the window cannot be closed by ESC, navigation or by clicking outside of it. false by default.
  • closeWhileNavigating [boolean] - Close the window when you navigate the app from one route to another. true by default.

Interface: NgxAzhModalResultInterface< ResultT >

  • reason [NgxAzhModalReasonEnum] - Reason why the window was closed.
  • value [ResultT | undefined] - Data to transfer.
  • dontShowAgain [boolean] - Return true if you no longer wish to show this window to the user. The dontShowAgainId property must be passed in the window options when it is created.

Interface: NgxAzhModalComponentInterface< ResultT >

Every modal window must implement this interface.

  • result [NgxAzhModalResultSubject<ResultT>] - You can subscribe to get the result of the modal window. You don't need to unsubscribe from "result". This happens automatically.

Enum: NgxAzhModalReasonEnum

  • ESCAPE - closed by ESC;
  • BACKDROP - closed by clicking outside;
  • NAVIGATION - closed by navigation;
  • CANCEL - closed by ModalResultSubject.cancel();
  • CONFIRM - closed by ModalResultSubject.confirm();

Enum: NgxAzhModalSizeEnum

Applies the following CSS classes to a modal window component.

  • SMALL - .azh-modal--small
  • MEDIUM - .azh-modal--medium
  • LARGE - .azh-modal--large
  • FULLSCREEN - .azh-modal--fullscreen

License

MIT