Search code examples
angularangular-validation

Angular Error As Cannot find control with path: '_OSkilss -> 0 -> Imageuploade'


Please Help me what Error it's this Is I'm getting While doing Form Registration

ngOnInit(){
    this._MyregisterForm = this.formBuilder.group({
                  _OSkilss: this.formBuilder.array([
            this.Addctrls()
        ])
    });
}
   Addctrls():FormGroup{
        return this.formBuilder.group({
            SkillName:['',Validators.required],
            SScCertificate:['',Validators.required]
        })
    }

My Html Page is

<form [formGroup]="_MyregisterForm">
    <div formArrayName="_OSkilss" *ngFor="let education of _MyregisterForm.get('_OSkilss').controls; let i = index">
        <div [formGroupName]="i">
            <input type="text" formControlName="SkillName"> <br>
            <input type="file" formControlName="Imageuploade" (change)="handlesscFile($event.target.files)"><br>

        </div>
    </div>
</form>

Solution

  • The issue is pretty straightforward though, you are trying to access Impageupload control in your template which was never defined in your _OSkilss control array.

    All you need to add that control in Addctrls() method.

    Impageupload:['', Validators.required]