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 { DynamicFormComponent, FormFieldConfig } from '@abp/ng.components/dynamic-form'; |
||||
import { FormConfigService } from './form-config.service'; |
import { FormConfigService } from './form-config.service'; |
||||
|
|
||||
@Component({ |
@Component({ |
||||
selector: 'app-dynamic-form-page', |
changeDetection: ChangeDetectionStrategy.OnPush, |
||||
templateUrl: './dynamic-form-page.component.html', |
selector: 'app-dynamic-form-page', |
||||
imports: [DynamicFormComponent], |
templateUrl: './dynamic-form-page.component.html', |
||||
|
imports: [DynamicFormComponent], |
||||
}) |
}) |
||||
export class DynamicFormPageComponent implements OnInit { |
export class DynamicFormPageComponent { |
||||
readonly dynamicFormComponent = viewChild(DynamicFormComponent); |
readonly dynamicFormComponent = viewChild(DynamicFormComponent); |
||||
protected readonly formConfigService = inject(FormConfigService); |
protected readonly formConfigService = inject(FormConfigService); |
||||
|
|
||||
formFields: FormFieldConfig[] = []; |
readonly formFields = toSignal(this.formConfigService.getFormConfig(), { |
||||
|
initialValue: [] as FormFieldConfig[], |
||||
|
}); |
||||
|
|
||||
ngOnInit() { |
submit(formData: any) { |
||||
this.formConfigService.getFormConfig().subscribe(config => { |
console.log('✅ Form Submitted Successfully!', formData); |
||||
this.formFields = config; |
console.table(formData); |
||||
}); |
|
||||
} |
|
||||
|
|
||||
submit(formData: any) { |
alert('✅ Form submitted successfully! Check the console for details.'); |
||||
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(); |
|
||||
} |
|
||||
|
|
||||
cancel() { |
this.dynamicFormComponent()?.resetForm(); |
||||
console.log('❌ Form Cancelled'); |
} |
||||
alert('Form cancelled'); |
|
||||
this.dynamicFormComponent().resetForm(); |
cancel() { |
||||
} |
console.log('❌ Form Cancelled'); |
||||
|
alert('Form cancelled'); |
||||
|
this.dynamicFormComponent()?.resetForm(); |
||||
|
} |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue