Below is an Angular reactive form implementation for the given services. It includes input fields with formControlName for each service. Special handling is done for Journal Submission and Conference as per your requirements.
// In your component.ts file
import { Component } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
@Component({
selector: 'app-service-form',
templateUrl: './service-form.component.html',
styleUrls: ['./service-form.component.css']
})
export class ServiceFormComponent {
serviceForm: FormGroup;
services: string[] = [
"Thesis Writing", "Dissertation Help", "Research Proposal", "Grammar Check",
"Formatting", "Plagiarism Check", "Plagiarism Removal", "Paper Writing",
"Journal Submission", "Synopsis Writing", "PowerPoint Presentation", "Implementation Help",
"Conference", "Pre Viva PPT", "Main Viva PPT", "ALL Work Shop", "Literature Review",
"Patent Assistance", "Book Chapter Writing", "Thesis Presentation", "Viva Prep"
];
constructor(private fb: FormBuilder) {
this.serviceForm = this.fb.group({
thesisWriting: [''],
dissertationHelp: [''],
researchProposal: [''],
grammarCheck: [''],
formatting: [''],
plagiarismCheck: [''],
plagiarismRemoval: [''],
paperWriting: [''],
journalSubmission: this.fb.group({
scopus: [''],
ugc: [''],
paperReview: this.fb.group({
journalName: ['', Validators.required],
issnNo: ['', Validators.required],
publicationDate: ['', Validators.required]
})
}),
synopsisWriting: [''],
powerPointPresentation: [''],
implementationHelp: [''],
conference: this.fb.group({
conferenceName: ['', Validators.required],
certificationName: ['', Validators.required]
}),
preVivaPPT: [''],
mainVivaPPT: [''],
allWorkShop: [''],
literatureReview: [''],
patentAssistance: [''],
bookChapterWriting: [''],
thesisPresentation: [''],
vivaPrep: ['']
});
}
onSubmit() {
console.log(this.serviceForm.value);
}
}
<!-- In your component.html file -->
<form [formGroup]="serviceForm" (ngSubmit)="onSubmit()">
<!-- Standard Single Upload Fields -->
<div *ngFor="let service of services">
<div *ngIf="!['Journal Submission', 'Conference'].includes(service)">
<label>{{ service }}</label>
<input type="file" [formControlName]="service.replace(' ', '').toLowerCase()" />
</div>
</div>
<!-- Journal Submission Fields -->
<div formGroupName="journalSubmission">
<label>Scopus</label>
<input type="file" formControlName="scopus" />
<label>UGC</label>
<input type="file" formControlName="ugc" />
<div formGroupName="paperReview">
<label>Journal Name</label>
<input type="text" formControlName="journalName" />
<label>ISSN No.</label>
<input type="text" formControlName="issnNo" />
<label>Publication Month/Year</label>
<input type="month" formControlName="publicationDate" />
</div>
</div>
<!-- Conference Fields -->
<div formGroupName="conference">
<label>Conference Name</label>
<input type="file" formControlName="conferenceName" />
<label>Certification Name</label>
<input type="file" formControlName="certificationName" />
</div>
<button type="submit">Submit</button>
</form>
Key Points:
- Standard Services: Use
*ngFor to generate file upload fields dynamically.
- Journal Submission:
- Scopus and UGC: File upload fields.
- Paper Review: Text inputs for journal details (name, ISSN, publication date).
- Conference:
- Two file upload fields for conference name and certification.
- FormControlName: Automatically generated from service names (spaces removed, lowercase).
This setup ensures proper form grouping and validation for the specified services.