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

angular-dynamic-dialog

v1.0.7

Published

Angular-dynamic-dialog is a library for building dynamic dialog, here you can embed a component to render the dialog's content. Customizing to your liking

Downloads

67

Readme

AngularDynamicDialog

Angular-dynamic-dialog is a library for building dynamic dialog, here you can embed a component to render the dialog's content. Customizing to your liking

Demo

https://gecoreto.github.io/angular-dynamic-dialog/

Install

$ npm i angular-dynamic-dialog

Import the module

// app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { GecoDialogModule } from 'angular-dynamic-dialog'; // <-- import the module
import { MyDynamicContentComponent } from './myDynamicContent.component';
import { AppComponent } from './app.component';

@NgModule({
    imports: [
              BrowserModule,
              GecoDialogModule // <-- include it in your app module
             ],
    declarations: [MyDynamicCotentComponent],  
    bootstrap: [MyComponent],
    entryComponents: [MyDynamicCotentComponent] // <-- include it for your dynamic content
})
export class MyAppModule {}

Usage

Render the html of your component that will be the content of the modal

Content html of DynamicCotentExampleComponent

<div class="modal-header">
  <h5 class="modal-title">Modal title</h5>
  <button type="button" class="close" (click)="dialogRef.closeModal()" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>
<div class="modal-body">
  <p>Modal body text goes here.</p>
</div>
<div class="modal-footer">
  <button type="button" class="btn btn-primary">Save changes</button>
  <button type="button" class="btn btn-secondary" (click)="dialogRef.closeModal()">Close</button>
</div>

Opening the modal

import { GecoDialog } from 'angular-dynamic-dialog'; // <-- import the dynamic dialog

public constructor(private modal: GecoDialog) {
}

//The first parameter is the component to be rendered in the modal's content
//The second parameter is the modal's configuration
let modal = this.modal.openDialog(DynamicCotentExampleComponent, {
  //Inject data
  data: { name: 'David' },
  //Options: 'bootstrap', 'none'
  useStyles: 'none' 
});
//Event when closing the modal
modal.onClosedModal().subscribe(() => {
  alert('Closed modal!!!');
});
//Event when opening the modal
modal.onOpenModal().subscribe(null, null, () => {
  alert('open modal');
});

Options openDialog()

The parameters are optional

Available Options

|Parameter | Type | Explanation | |--- |--- |--- | | data | {} | set the data for the inject in your dynamic content | | useStyles | string | set the style for use in the modal. Can either be 'bootstrap' or 'none' |

Use the styles

If you use Bootstrap 4

let modal = this.modal.openDialog(DynamicCotentExampleComponent, {
  //Options: 'bootstrap', 'none'
  useStyles: 'bootstrap' 
});

otherwise, just use the default styles:

let modal = this.modal.openDialog(DynamicCotentExampleComponent, {
  //Options: 'bootstrap', 'none'
  useStyles: 'none' 
});

Styling

All the elements have specific css classes, please just look them up using the element inspector.

Receiving data in your dynamic content

Inject the data into your constructor

import { 
    GECO_DATA_DIALOG, 
    GecoDialog, 
    GECO_DIALOG_REF, 
    GecoDialogRef } from 'angular-dynamic-dialog'; // <-- import the components
    
  constructor(
  @Inject(GECO_DATA_DIALOG) public data: any,
  @Inject(GECO_DIALOG_REF) public dialogRef: GecoDialogRef
) { 
  console.log('Data =>', this.data);
  console.log('dialogRef =>', this.dialogRef);
}

Emitting action from the dynamic component

Close dialog from your component

<button type="button" (click)="dialogRef.closeModal()">Close Modal</button>

Contribute

If you want to help me in the development of this project do not hesitate, you have all the script available to you.

Suggestions