Questions tagged [angular-providers]

The service providers are constructor functions. When instantiated they must contain a property called $get, which holds the service factory function.

angularjs doc

151 questions
31
votes
9 answers

Possibly unhandled rejection in Angular 1.6

I have a code with AngularJS: service.doSomething() .then(function(result) { //do something with the result }); In AngularJS 1.5.9 when I have error in the .then() section like: service.doSomething() .then(function(result) { var x…
14
votes
2 answers

Angular Async Factory Provider

I would like to set up a factory that does async work to return a service, and then provide that factory to a factory provider to provide that service to a component when it loads. However, when the provider injects the TestService into the…
Sharpiro
  • 2,004
  • 14
  • 24
11
votes
1 answer

What does multi:true mean in providers in angular4

I am using HTTP_INTERCEPTORS in angular4. For this, I have created HttpServiceInterceptor class that implements HttpInterceptor interface and provide the defintion for intercept method. Then registered provider for HTTP_INTERCEPTORS like…
Sunil Garg
  • 10,122
  • 12
  • 92
  • 133
9
votes
2 answers

Why does this test for the angular-google-maps provider fail?

I'm trying to test a module that uses angular-google-maps. It is failing because angular.mock.inject cannot find uiGmapGoogleMapApiProvider: Error: [$injector:unpr] Unknown provider: uiGmapGoogleMapApiProviderProvider <-…
8
votes
4 answers

Angular: Metadata collected contains an error that will be reported at runtime: Lambda not supported

In my Angular app, I'm trying to use a factory provider in my module: export function getMyFactory(): () => Window { return () => window; } @NgModule({ providers: [ { provide: WindowRef, useFactory: getMyFactory() }, ], }) export class…
7
votes
0 answers

angular injectable.providedIn vs module.providers

A Common practice is to include services in @NgModule.providers @NgModule({ providers: [ MessageService ] }) According to Angular tutorial, you can provide a service without specifying it in the @NgModule decorator, by using…
yuval.bl
  • 3,566
  • 2
  • 13
  • 28
7
votes
2 answers

Lazy loading and providers strategy

Right now, using Angular v5, while using lazy loading, I load all my providers in app.module.ts which I guess isn't maybe the best strategy because this won't speed up my app boot time, specially because I've got something like 50 custom providers…
David Dal Busco
  • 6,683
  • 10
  • 41
  • 84
6
votes
1 answer

When to use Angular 2 factory functions?

I can't imagine a situation where I need to use a factory provider. According to the offical docs https://angular.io/docs/ts/latest/guide/dependency-injection.html the situation is that one may not be able to access a service (service-b) from…
johncol
  • 444
  • 6
  • 11
5
votes
1 answer

Multiple ngrx store in one application

We are developers of a module of a big Angular application. Modules are independent from each other, they are developed by separate teams. We would like to use an ngrx store in our module. An other module already has an ngrx store. If I try to add a…
elcsiga
  • 170
  • 1
  • 7
5
votes
1 answer

No Provider for router in Angular 2

As a newbie, I am having issues setting up routes in Angular 2. Though I am pretty sure, it is something very basic I am missing. All I want is my App Component to load up and show me the title. And just below it, a link that would load up the…
StrugglingCoder
  • 4,231
  • 11
  • 55
  • 90
4
votes
2 answers

error:NullInjectorError: No provider for Router

I have to test one component and get this error NullInjectorError: R3InjectorError(DynamicTestModule)[AuthenticationService -> Router -> Router]: NullInjectorError: No provider for Router!**" The component I'm testing have two dependencies and I…
4
votes
3 answers

NullInjectorError: StaticInjectorError on NgxSpinnerService; NullInjectorError: No provider for t! while trying hosting in firebase

I am trying to host my app in firebase everything works fine in localhost but when I successfully host app in firebase at firebase domain, it shows: NullInjectorError: StaticInjectorError(wo)[class{constructor(t,e) at SpinnerService at content is…
4
votes
2 answers

How to inject a dependency into a provider with given injection token?

I'm using an Angular plugin, which needs to be configured by providing a configuration object using an InjectionToken that the plugin exports. import { pluginToken } from 'plugin'; @NgModule({ providers: { // Configure the plugin // …
Robert Kusznier
  • 4,696
  • 7
  • 33
  • 62
4
votes
1 answer

The semantics of @Injectable(providedIn: 'root')?

Just want to make sure I understand the semantics of @Injectable(providedIn: 'root'). Prior to Angular 6 if we import a module from NPM that contains a service we would declare that module in our app module such that the entire application has…
4
votes
1 answer

Import a service from another module

I am currently learning the Angular framework (version 5) after developing 2 years with the AngularJS 1.x framework, so I ask myself a lot of questions and one of them is the way to properly import a service provided by another module that the one…
Alexandre D.
  • 641
  • 1
  • 8
  • 27
1
2 3
10 11