0

I'm getting the following error when creating a reactive form in Angular 10:

No provider for ControlContainer core.js:4127 ERROR Error: NodeInjector: NOT_FOUND [ControlContainer]

HTML Code

    <form [formGroup]="signupForm" (ngSubmit)="onSubmit()">
    
            <div class="form-group">
              <label for="projectName">Project Name</label>
              <input formControlName="projectName" type="text" class="form-control" id="projectName"> 
            </div>
    
            <div class="form-group">
              <label for="email">E-Mail</label>
              <input formControlName="mail" type="text" class="form-control" id="mail"> 
            </div>
    
            <div class="form-group">
              <label for="prjectStatus">Project Status</label>
              <select formControlName="projectStatus" class="form-control" id="prjectStatus">
                <option value="stable">Stable</option>
                <option value="critical">Critical</option>
                <option value="finished">Finished</option>
              </select> 
            </div>
            <div class="form-group">
                <button type="submit" class="btn btn-primary">Submit</button>
            </div>
          </form>

Typescript Code:

     import { Component, OnInit } from '@angular/core';
        import { FormControl, FormGroup } from '@angular/forms';
        
        @Component({
          selector: 'app-root',
          templateUrl: './app.component.html',
          styleUrls: ['./app.component.css']
        })
    
        export class AppComponent implements OnInit {
        
          signupForm: FormGroup;
        
          ngOnInit(): void {
        
            this.signupForm = new FormGroup({
              'projectName' : new FormControl(null),
              'email' : new FormControl(null),
              'projectStatus' : new FormControl('critical')
            });
          }
        }
2

2 Answers 2

1

Try importing FormsModule in addition to ReactiveFormsModule in the relevant module. (or app module if you want it available globally)

Sign up to request clarification or add additional context in comments.

Comments

0

Solved by adding ReactiveFormsModule to the imports Array of app.module.ts & importing ReactiveFormsModule from '@angular/forms'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.