1.2.1 • Published 5 years ago

ir-alert v1.2.1

Weekly downloads
12
License
-
Repository
-
Last release
5 years ago

ir-alert

Angular 6 alert component

Usage

  1. Install from npm:
npm install ir-alert --save
  1. Import IrAlertModule to app.module.ts:
import { IrAlertModule } from 'ir-alert';
@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        IrAlertModule
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }
  1. Import IrAlertService to component that you want to use the alert:
import { IrAlertService } from 'ir-alert';
  1. Use the alert service:
constructor(public alert: IrAlertService) {
    this.alert.showAlert({
        title: 'IrAlert',
        message: 'Hello World!'
    });
}

Parameters

ParamType
configIrAlertConfig
buttonsIrAlertButton[]
inputsIrAlertInput[]

IrAlertConfig

You can use MatDialogConfig for IrAlertConfig with these two extra configs:

ConfigType
titleString
message?String

IrAlertButton

AttributeType
textString
handler?Function

sample:

[
    {
        text: 'Yes',
        handler: () => {
            console.log('You pressed "Yes"');
        }
    },
    {
        text: 'No',
        handler: () => {
            console.log('You pressed "No"');
        }
    }
]

IrAlertInput

AttributeType
typeString - 'text', 'number', 'tel' , 'password', 'textarea', 'radio', 'checkbox', 'h1', 'h2', 'h3', 'h3', 'h4', 'h5'
nameString
value?String
placeholder?String
label?String - require if type is radio or checkbox
multiLine?Boolean - show radio or checkbox in multiline or inline
rows?Number - number of rows in textarea
group?IrAlertRadioGroup[] - require if type is radio

IrAlertRadioGroup:

AttributeType
valueString
labelString

Sample

constructor(public alert: IrAlertService) {
    this.alert.showAlert({
        title: 'IrAlert',
        message: 'Hello World!'
    }, [
        {
            text: 'Yes',
            handler: (values) => {
                console.log(values);
            }
        },
        {
            text: 'No',
            handler: () => {
                console.log('You pressed "No"');
            }
        }
    ], [
        {
            type: 'text',
            name: 'name',
            placeholder: 'Name'
        },
        {
            type: 'text',
            name: 'lastname',
            placeholder: 'LastName'
        }
    ]);
}