20 lines
478 B
TypeScript
20 lines
478 B
TypeScript
import { Directive } from '@angular/core';
|
|
import { FormGroup } from '@angular/forms';
|
|
import { AutoUnsubscribe, hasFormChanged } from '../utils';
|
|
|
|
@Directive()
|
|
export abstract class BaseFormComponent extends AutoUnsubscribe {
|
|
form!: FormGroup;
|
|
initialFormValue;
|
|
|
|
get changed(): boolean {
|
|
return hasFormChanged(this.form, this.initialFormValue);
|
|
}
|
|
|
|
get valid(): boolean {
|
|
return this.form?.valid;
|
|
}
|
|
|
|
abstract save(): Promise<void>;
|
|
}
|