npm.io
0.0.15 • Published 8 years ago

fe-modal

Licence
MIT
Version
0.0.15
Deps
0
Vulns
0
Weekly
0

F.E.Mock fe-modal

Dependencies

  • Angular >=4.0.0

Install

You can get it on npm.

npm install fe-modal --save

Usage

.angular-cli.json

"apps": [
    {
        ...
        "styles": [
            "../node_modules/fe-modal/modal.less"
        ],
        ...
    }
]

app.module.ts:

import { ModalModule } from 'fe-modal';

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        ...
        ModalModule.forRoot(),
    ],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule {}

Use in components:

import { ModalService } from 'fe-modal';   

@Component({
    selector: 'app-demo',
    templateUrl: './app-demo.component.html',
    styleUrls: ['./app-demo.component.less']
})
export class DemoComponent {

    constructor (private modal: ModalService) {}

    dialog () {
        this.modal.dialog({ template: FormComponent });
    }

    alert () {
        this.modal.alert({ template: 'alert' });
    }

    loading () {
        this.modal.loading({ template: 'loading' });
    }

    remove (id: string) {
        this.modal.confirm({
            template: 'Do not restore after deletion, please operate carefully',
            confirmCallback: () => {
                // code ...
            }
        });
    }
}

Keywords