Angular programmers may face these types of common errors all the way in their programming path, here are the few issues and fixes to them.
1) Can't bind to 'formGroup' since it isn't a known property of 'form'
The ReactiveFormsModule might be in missing in the app.module.ts imports section
Import the ReactiveFormsModule
imports: [
ReactiveFormsModule]
And don’t forgot to specify the imports
import { ReactiveFormsModule } from
'@angular/forms';
2) Can't bind to 'ngModel' since it isn't a known property of 'input'.
Cause: The FormsModule might be in missing in the app.module.ts imports section
Import the FormsModule
imports: [
BrowserModule,
AppRoutingModule,
FormsModule
],
And don’t forgot to specify the imports
import { FormsModule } from
'@angular/forms';
3) NullInjectorError: No provider for HttpClient!
Cause: This may be due to when the project got upgraded
To Fix this, Apply the HttpClient to available throughout the application
Import the HttpClientModule
import { HttpClientModule } from
'@angular/common/http';
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
HttpClientModule
],
4) Can't resolve all parameters for Service
Cause:
a) This may be due to missing @Injectable() decorator
b) Or the providedIn is set to accessible locally
To Fix this, Apply the @Injectable() to make available the service throughout the application
@Injectable() is case sensitive
Example:
@Injectable({
providedIn: 'root'
})
export class XxxService {
constructor() { }
}
providedIn: “root” will apply the permissions to the service at root level, means this is fully available to the entire application
Comments