angular: ERROR Error: Uncaught (in promise): Error: StaticInjectorError[e]:
https://image.prntscr.com/image/4Huq_HhQTHyIjYKH0ztgKw.png
ERROR Error: Uncaught (in promise): Error: StaticInjectorError[e]: StaticInjectorError[e]: NullInjectorError: No provider for e!
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 36
- Comments: 94 (2 by maintainers)
Importing both HttpModule and HttpClientModule fixes the problem.
import { HttpClientModule } from '@angular/common/http'; import { HttpModule } from '@angular/http';
Add import { HttpModule } from ‘@angular/http’; in app.module.ts
in app module Step 1 add import import { HttpModule } from ‘@angular/http’; Step 2 add HttModule in : imports: [ HttpModule
], …
Maybe you need to add in the service import { Http ,HttpModule} from ‘@angular/http’ too
still not working for me
@amitkprajapati import HttpClientModule in
app.module.ts
also not working for me , same error
providers: [ AuthGuard, CookieService, CompanyService, PolicyService, CommunicationService, AuthenticationService ]
Have to add app.module.ts under provider section to make them available in providers
Problem fixed!! HUHU
Worked by importing
HttpClientModule
even I am not using this module in whole app… that’s wired.@ilivestrong all services need to configure in the providers section of the app.module.ts
Something like this
providers: [ AuthGuard, CookieService, CompanyService, PolicyService, CommunicationService, AuthenticationService ]
Add import { HttpModule } from ‘@angular/http’; in app.module.ts for Http Or Add import {HttpClientModule} from ‘@angular/common/http’ in app.module.ts for httpclient
I had same issue but after importing “HttpModule” in “app.module.ts” it worked fine for me.
Thanks. Keep Sharing.
@ilivestrong have you included
ReactiveFromsModule
in import array of app.module.tsUsing Angular 6 and tried every suggestion… the problem continues… pls suggest
Not working with any of the solutions.
FILES -----

I solve this by following two steps:
import { HttpModule } from ‘@angular/http’; and then add HttpModule to imports
,imports: [ HttpModule, BrowserModule, IonicModule.forRoot(MyApp), ], This fixes the problem for me. you can also import import { HttpClientModule } from ‘@angular/common/http’; for convenience sake
I had the same problem when I moved a property to a component inside
constructor()
parameters. It was solved when I moved it out back.You need provide your dataservices import … import { DataService } from ‘…/dataservice’;
@Component({ selector: '… templateUrl: … styleUrls:…, providers: [DataService] })
angular-cli version is too high, Problem fixed
this worked for me
@Injectable({ providedIn: ‘root’, })
i solved this problem. at ‘app.module.ts’ add
and, imports: [ BrowserModule, HttpModule, HttpClientModule, IonicModule.forRoot(MyApp) ]
@ilivestrong I got the same. Adding
providers: [UserService]
in my userListComponent fixed it.This component is imported by my user-module which itself is imported in app-module.
Hope it helps !
add
FreezerService
intoproviders
array of app.module.tssame here
same issue here (ive imported the httpmodule, but still not working)
In the auth.guard.ts
Apart from above solutions… I think removing the NavCtrl from service also helps. Seems there is conflict between NavCtrl of Component and Service/Provider
Stop ionic and rerun “
ionic serve
” to show real error message to you.Not working for me
I ended up importing HttpClientModule and the auth-guard file into app.module.ts, supplied the auth guard dependency in the providers array, and the HttpClientModule into the imports array.
note: I did not need to downgrade @angular/cli
not working for me…
I solved import { HttpClientModule } from ‘@angular/common/http’; import { HttpModule } from ‘@angular/http’;
imports: [ BrowserModule, HttpModule, HttpClientModule, IonicModule.forRoot(MyApp) ],
for mi
As was mentioned above, this worked for me: In
app.module.ts
importHttpClientModule
and include it in your imports array. In your service use HttpClient (http: HttpClient
in constructor)Just verify Your Code with below one:
the above Code resolve the issue
This error was caused by introducing angular2-cookie for me. It works during “ng serve”, but not “ng build --prod”. Solution was simply removing it from the project. Didn’t really use it anyways.
That is because we have not injected our services in app module.
We have to pass our service at 2 places in app.module.ts importing the service added them in providers
import {ConfigService} from ‘./providers/config.service’;
… providers: [ConfigService], …
I also got this working by importing HttpModule from angular/http@5.2.9 in app.module.ts
I got this error in Angular 5.2.7 and importing HttpClientModule to the app.module.ts solved the the problem, don’t forget to add HttpClientModule to the imports: [] and don’t forget the service provider too providers: []
Just for information ~
HttpModule
~ is deprecated in favor ofHttpClientModule
from@angular/common/http
package; use the latest one to make upgrade easy 👍The above one is right .you should define the it in provider of app.module file .
On 19-Jan-2018 1:49 PM, “Jerson” notifications@github.com wrote:
@kverma17 add
Camera
to provider array in side of app.module.ts and donot forget to import it 😃I am not sure camera will work properly in browser but the error you have posted will go away.