Notebook Page Margin

    ionic2-extend-alert
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.2 • Public • Published

    ionic2-extend-alert

    Ionic2 extended version of alert component

    Extend

    1. Set dialog auto-cancel

    Install

    npm install ionic2-extend-alert --save

    Use

    Import module

    import { NgModule, ErrorHandler } from '@angular/core';
    import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
    import { MyApp } from './app.component';
    ...
    import { ExtendAlertModule } from 'ionic2-extend-alert'
    
    
    @NgModule({
      declarations: [
        MyApp,
        ...
      ],
      imports: [
        ExtendAlertModule,
        IonicModule.forRoot(MyApp)
      ],
      bootstrap: [IonicApp],
      entryComponents: [
        MyApp,
        ...
      ],
      providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}]
    })
    export class AppModule {}
    

    Your component

    import { Component } from '@angular/core';
    import {NavController, NavParams} from 'ionic-angular';
    ...
    import { AlertController } from 'ionic2-extend-alert/dist/alert';
    
    @Component({
      selector: 'page-home',
      templateUrl: 'home.html'
    })
    export class HomePage {
    
      constructor(
        ...
        public alertCtrl: AlertController
    
      ) {
      }
    
    
      presentConfirm() {
        let alert = this.alertCtrl.create({
          title: 'Hi!',
          message: 'Hello Ionic2',
          buttons: [
            {
              text: 'cancel',
              role: 'cancel',
              handler: () => {
                console.log('Cancel clicked');
              }
            },
            {
              text: 'ok',
              time:6000, // set auto-cancel time
              handler: () => {
                console.log('Buy clicked');
              }
            }
          ]
        });
        alert.present();
      }
    }
    

    Extend API

    Button options

    Property Type Description
    time number auto-cancel time

    Environment

    Cordova CLI: 6.4.0
    Ionic Framework Version: 2.0.0
    Ionic CLI Version: 2.1.18
    Ionic App Lib Version: 2.1.9
    Ionic App Scripts Version: 1.0.0
    ios-deploy version: Not installed
    ios-sim version: Not installed
    OS: macOS Sierra
    Node Version: v6.9.2
    Xcode version: Xcode 8.2.1 Build version 8C1002
    

    Install

    npm i ionic2-extend-alert

    DownloadsWeekly Downloads

    1

    Version

    0.0.2

    License

    MIT

    Last publish

    Collaborators

    • hsuanlee