Skip to content

Instantly share code, notes, and snippets.

@mwagena
Created March 21, 2017 10:46
Show Gist options
  • Save mwagena/d46081aabdf8ced64fb16807729b410e to your computer and use it in GitHub Desktop.
Save mwagena/d46081aabdf8ced64fb16807729b410e to your computer and use it in GitHub Desktop.
Button with confirmation
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