I'm encountering an issue where I am being advised to import "FomsModule", but it is already imported in my code.
I attempted to include "ReactiveFormsModule" as well, but the problem persists.
Here is the complete error message:
src/app/components/create/create.component.html:7:51 - error NG8003: No directive found with exportAs 'ngModel'.
<input type="text" name="name" #name="ngModel" [(ngModel)="project.name"]>
src/app/components/create/create.component.ts:7:16
templateUrl: './create.component.html',
Error occurs in the template of component CreateComponent.
This is my component's template:
<form #projectForm = "ngForm" (ngSubmit)="onSubmit(projectForm)">
<p>
<label for="name">Nombre</label>
<input type="text" name="name" #name="NgModel" [(ngModel)="project.name"]>
</p>
</form>
Below is my component's code:
import { Component, OnInit } from '@angular/core';
import { Project } from '../../models/project';
import { ProjectService } from '../../services/project.service';
@Component({
selector: 'app-create',
templateUrl: './create.component.html',
styleUrls: ['./create.component.css'],
providers: [ProjectService]
})
export class CreateComponent implements OnInit {
constructor(
) {
}
ngOnInit(): void {
}
}
Finally, here is my app.module:
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { CreateComponent } from './components/create/create.component';
@NgModule({
declarations: [
AppComponent,
CreateComponent,
],
imports: [
FormsModule,
ReactiveFormsModule,
BrowserModule,
routing,
HttpClientModule,
],
providers: [appRoutingProviders],
bootstrap: [AppComponent]
})
export class AppModule { }
Any insights on what might be causing this error?