Skip to content

Instantly share code, notes, and snippets.

@rainerhahnekamp
Last active November 11, 2021 20:21
Show Gist options
  • Save rainerhahnekamp/58406ed3f4ccb69cfe2e3d84336d69f8 to your computer and use it in GitHub Desktop.
Save rainerhahnekamp/58406ed3f4ccb69cfe2e3d84336d69f8 to your computer and use it in GitHub Desktop.
export class CustomerComponent {
formGroup = new FormGroup({});
@Input() customer: Customer | undefined;
@Output() save = new EventEmitter<Customer>();
@Output() remove = new EventEmitter<Customer>();
fields: FormlyFieldConfig[] = [
// form configuration
];
submit(customer: Customer) {
if (this.formGroup.valid) {
this.save.emit(this.formGroup.value);
}
}
handleRemove(customer: Customer) {
if (confirm(`Really delete ${customer}?`)) {
this.remove.emit(this.customer);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment