0.1.9 • Published 6 years ago

ngx-dynamic-modal v0.1.9

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Angular dynamic modal

Simple creating of modal from any (REALLY ANY) component

Installation

npm install ngx-dynamic-modal --save

Usage

Angular 2+

####Module with needed parent component

import {ModalModule} from 'ngx-dynamic-modal';
@NgModule({
    imports: [ModalModule]
})
export class AppModule{};

####Parent component

import {ModalService} from 'ngx-dynamic-modal';
import {ChildComponent} from './child-component';

@Component({
    //...
})
export class ParentComponent {
    constructor(private modalService: ModalService) {}

    callback(res) {
        console.log(res)
    }

    openModal() {
        const data = {a: 1, b: 2};
        this.modalService.addDynamicComponent(ChildComponent, {data}, (res) => {
            this.callback(res)
        })
    }
};

####Child component

import {ModalComponent} from 'ngx-dynamic-modal';

@Component({
    //...
})
export class ChildComponent extends ModalExtended implements OnInit {

    constructor(){
        super();
    }

    ngOnInit() {
        //get data
        console.log(this.data); //{a: 1, b: 2}
    }

    onExit(){
        //to run callback
        this.applyCallback('any data');
        //to destroy modal component
        this.close();
    }
};
0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago