mirror of https://github.com/abpframework/abp.git
9 changed files with 94 additions and 57 deletions
@ -1,38 +1,34 @@ |
|||
import { Component, inject, OnInit, viewChild } from '@angular/core'; |
|||
import { ChangeDetectionStrategy, Component, inject, viewChild } from '@angular/core'; |
|||
import { toSignal } from '@angular/core/rxjs-interop'; |
|||
import { DynamicFormComponent, FormFieldConfig } from '@abp/ng.components/dynamic-form'; |
|||
import { FormConfigService } from './form-config.service'; |
|||
|
|||
@Component({ |
|||
selector: 'app-dynamic-form-page', |
|||
templateUrl: './dynamic-form-page.component.html', |
|||
imports: [DynamicFormComponent], |
|||
changeDetection: ChangeDetectionStrategy.OnPush, |
|||
selector: 'app-dynamic-form-page', |
|||
templateUrl: './dynamic-form-page.component.html', |
|||
imports: [DynamicFormComponent], |
|||
}) |
|||
export class DynamicFormPageComponent implements OnInit { |
|||
readonly dynamicFormComponent = viewChild(DynamicFormComponent); |
|||
protected readonly formConfigService = inject(FormConfigService); |
|||
export class DynamicFormPageComponent { |
|||
readonly dynamicFormComponent = viewChild(DynamicFormComponent); |
|||
protected readonly formConfigService = inject(FormConfigService); |
|||
|
|||
formFields: FormFieldConfig[] = []; |
|||
readonly formFields = toSignal(this.formConfigService.getFormConfig(), { |
|||
initialValue: [] as FormFieldConfig[], |
|||
}); |
|||
|
|||
ngOnInit() { |
|||
this.formConfigService.getFormConfig().subscribe(config => { |
|||
this.formFields = config; |
|||
}); |
|||
} |
|||
submit(formData: any) { |
|||
console.log('✅ Form Submitted Successfully!', formData); |
|||
console.table(formData); |
|||
|
|||
submit(formData: any) { |
|||
console.log('✅ Form Submitted Successfully!', formData); |
|||
console.table(formData); |
|||
|
|||
// Show success message
|
|||
alert('✅ Form submitted successfully! Check the console for details.'); |
|||
|
|||
// Reset form after submission
|
|||
this.dynamicFormComponent().resetForm(); |
|||
} |
|||
alert('✅ Form submitted successfully! Check the console for details.'); |
|||
|
|||
cancel() { |
|||
console.log('❌ Form Cancelled'); |
|||
alert('Form cancelled'); |
|||
this.dynamicFormComponent().resetForm(); |
|||
} |
|||
this.dynamicFormComponent()?.resetForm(); |
|||
} |
|||
|
|||
cancel() { |
|||
console.log('❌ Form Cancelled'); |
|||
alert('Form cancelled'); |
|||
this.dynamicFormComponent()?.resetForm(); |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue