Created
March 21, 2017 10:46
-
-
Save mwagena/d46081aabdf8ced64fb16807729b410e to your computer and use it in GitHub Desktop.
Button with confirmation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, EventEmitter, Output, Input } from '@angular/core'; | |
@Component({ | |
selector: 'delete-confirm', | |
template: ` | |
<button class="btn btn-danger" (click)="showConfirm()"> | |
{{btn_txt}} | |
</button> | |
`, | |
}) | |
export class DeleteConfirmComponent { | |
@Input('btn-text') btn_txt: string; | |
@Input('confirm-text') confirm_text: string; | |
@Output('confirmed') confirmed = new EventEmitter(); | |
showConfirm() { | |
// Emit value only when confirmed | |
if(confirm(this.confirm_text)) | |
this.confirmed.emit(true) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment