ng-modals
Version:
Make a modal in angular extremely easily with ng-modals. Installation to have a modal pop up is quick and easy.
88 lines (67 loc) • 2.14 kB
Markdown
# ng-modals
> Friendly modal creator for Angular 2+ projects
ng-modals allows for the creation of a modal with a few simple lines of code. It comes standard with a clean opening animation and also the ability to define the width and height of the modal and other cool features.
### Installation
```bash
npm install ng-modals --save
```
### API
Add the module to the `app.module.ts` as an import
```javascript
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import {NgModalsComponent, NgModalsDirective } from 'ng-modals';
export class AppModule { }
```
Then, in the a `component` file
```javascript
import { Component } from '@angular/core';
import { SomeOtherComponent } from './some/file/path';
export class AppComponent {
public isModalOpen = false;
public modalOptions = {
width: "70",
height: "70",
component: SomeOtherComponent,
data: {authors: [{name: "Joe Seph", books: 23}]}
}
toggleModal(){
this.isModalOpen = !this.isModalOpen;
}
}
```
Then in the `SomeOtherComponent` that you referenced in the `modalOptions` object..
```javascript
import { Component, OnInit, Input } from '@angular/core';
import { NgModalsInterface } from 'ng-modals';
export class SomeOtherComponent implements OnInit, NgModalsInterface {
data:any;
constructor() { }
ngOnInit() {
console.log(this.data);
}
}
```
#### You have now opened a new modal!