I have this error
ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'formGroup' since it isn't a known property of 'form'. ("<form [ERROR ->][formGroup]="formGroup" (ngSubmit)="onSubmit()" >
And I am using Angular 7.
What i am doing is creating a System that allow the user to upload a excel file
And now I am in the process of uploading data with the Help of Asp.net Core as the web api.
But i already have a problem with the Front End.
And the error is
Can't bind to 'formGroup' since it isn't a known property of 'form'.
And upon searching I found a solution, but it doesn't work for me.
This is one of the link i found. But it doesn't solved my problem
https://stackoverflow.com/questions/39152071/cant-bind-to-formgroup-since-it-isnt-a-known-property-of-form
Below is the simple Html component code for uploading
<form [formGroup]="formGroup" (ngSubmit)="onSubmit()" >
<div >
<input id="file" type="file" name="file" />
</div>
<div >
<button class="btn btn-primary">Submit</button>
</div>
</form>
Then i added code the component.ts
file
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { FormGroup, FormControl } from '@angular/forms';
@Component({
selector: 'app-data-ingestion',
templateUrl: './data-ingestion.component.html',
styleUrls: ['./data-ingestion.component.scss']
})
export class DataIngestionComponent implements OnInit {
formGroup = new FormGroup({
one: new FormControl
});
constructor(private http: HttpClient) { }
ngOnInit() {
}
onSubmit() {
console.log('I am called');
}
}
And i also modified the code in the app.module.ts
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
And i added the code in the imports array
imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule,
AppRoutingModule,
BrowserAnimationsModule,
LayoutModule,
OverlayModule,
HttpClientModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: createTranslateLoader,
deps: [HttpClient]
}
})
],
But the error is still there. Did i forgot to modify other file? Or did i do it wrong?