diff --git a/README.md b/README.md index c8d9fca..15dc094 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,15 @@ Adding the `[swal]` attribute to an element will attach the directive to it. The directive will listen for `click` events and display a SweetAlert modal, configured using the options you pass to the attribute. The options are of type [`SweetAlertOptions` (provided by sweetalert2)](https://github.com/limonte/sweetalert2/blob/master/sweetalert2.d.ts#L204), or a simple array of strings, of format `[title: string, text: string (, type: string)]`. +```typescript +class __API__ { + @Input() public set swal(options: SweetAlertOptions|SimpleSweetAlertOptions); + + @Output() public confirm: EventEmitter; + @Output() public cancel: EventEmitter; +} +``` + Simple confirmation dialog: ```html @@ -61,9 +70,56 @@ export class MyComponent { } ``` +### SwalComponent + +The library also provides a component, that can be useful for displaying other dialogs than confirmation ones. Others can prefer to use that to avoid having dialog-related logic in their codebehind. + +```typescript +class __API__ { + @Input() public type: SweetAlertType; + @Input() public title: string; + @Input() public text: string; + @Input() public html: string; + @Input() public options: SweetAlertOptions; + + @Output() public confirm: EventEmitter; + @Output() public cancel: EventEmitter; + + public show(): Promise; +} +``` + +Simple example: + +```html + + + +Or: + +