Questions tagged [angular2-providers]

52 questions
2
votes
1 answer

Observable BehaviorSubject Service - Singleton and providers

I have a simple component progressBar in order to display (or not) the progress bar. And a simple observable service. Here is the service : import { Injectable } from '@angular/core'; import { Http } from '@angular/http'; import { Observable }…
ByJC
  • 213
  • 1
  • 3
  • 9
1
vote
1 answer

Angular9 'No provided for ActivatedRoute'

I'm beginner in Angular 9. I'm following an online video tutorial to excercise on angular, but my code (same of the tutorial) had a problem and I don't know of to figure out. Actually, tutorial put routing stuffs all inside app.module.ts, but I use…
1
vote
1 answer

Angular 8 Lazy Loading. Questions regarding: imports, entryComponents and providers

i have exceeded the 2MB mark a while ago, so i decided to implement Lazy loading to deal with my hefty batches. Therefore I have questions regarding imports, entryComponents and providers. To water all of them down into one question: What do i…
Yoshy
  • 170
  • 2
  • 14
1
vote
0 answers

Code refactoring, can't reach data

As the title say i would like to refactor my code. I have a problem when i would like to put the API call in a external provider (if one day i have to use it, i will only import the new .ts file) , i can't reach the "weather" datas. Here is my…
1
vote
0 answers

Multiple service providers using same-named DI parameter (Angular 2)

In my Angular 2 project, I am using 2 different services in a single component. They both have required Injector parameters. The issue I am trying to resolve is that both DI parameters use the same name, but I do not know how to format my component…
1
vote
1 answer

Angular: How to globally listen to router events

I want to show a spinner whenever navigation occurs. How can I listen to router events globally so that I can show spinner on NavigationStart and hide it on NavigationEnd whenever routing occurs, like how we do with HttpInterceptor for globally…
karthikaruna
  • 3,042
  • 7
  • 26
  • 37
1
vote
2 answers

Using Angular 2+ forRoot pattern to pass callbacks into modules

I have created an Angular Module called DataModule which contains services for accessing my backend through a token-secured HTTP API. On HTTP access control errors such as 401 Unauthorized and 403 Forbidden I want to be able to redirect to /login or…
the-a-train
  • 1,123
  • 13
  • 32
1
vote
1 answer

what is the syntax for using multiple providers in component class?

I need to use an additional service in my component. It seems I should be able to do it like so @Component({ selector: 'page-home', templateUrl: 'home.html', providers: [firstService, additionalService] }) but it doesn't work.
Spilot
  • 1,495
  • 8
  • 29
  • 55
1
vote
1 answer

why the example of angular-webpack-stater don't state AppState in providers,however state Title which is aslo service

The address of the code is https://github.com/AngularClass/angular2-webpack-starter/blob/master/src/app/home/home.component.ts import { AppState } from '../app.service'; import { Title } from './title'; import { XLargeDirective } from…
wangd933
  • 33
  • 5
1
vote
2 answers

How to provide LOCALE_ID from an observable in Angular 2?

In Angular 2, in order to localize date pipe you need to provide LOCALE_ID. I have a service LocaleService that exposes locale$: Observable which implements BehaviorSubject. I don't want to add any state to this service, I want it to…
Ivan Zyranau
  • 879
  • 2
  • 14
  • 33
1
vote
1 answer

Ionic 2 / Angular 2 providers cannot be resolved

I am using Ionic 2 and have some problems with providers/injections since version 2.0.0. The error I keep getting is the following (with different providers, not only this one): Uncaught Error: Can't resolve all parameters for…
1
vote
1 answer

Angular2: How to inject two instances of the same service into multiple components?

Suppose that I have an Angular Service that looks like this: @Injectable() export class Clipboard { constructor(private multiple: Multiple, private di:DI, private injected:Injected, private things: Things){} // The clipboard has local…
sixtyfootersdude
  • 25,859
  • 43
  • 145
  • 213
1
vote
1 answer

Angular2 Dependency Injection: What's the "..." syntax I see before some injected package's name (ie 'providers = [...SomeProvider]')

I'm just getting started in Angular2 and normally injecting providers looks like: providers : [SomeProvider], However I have been seeing some packages that include a "..." before the provider name that is being injected like: providers :…
garrettmac
  • 8,417
  • 3
  • 41
  • 60
1
vote
1 answer

Provider changes in angular 2 final version

In angular 2.0.0-rc.1 we have created Provider using new Provider, refer below code snippet var constAccessor = new Provider(NG_VALUE_ACCESSOR, { useExisting: forwardRef(() => EJDefaultValueAccessor), multi: true }); var…
1
vote
1 answer

Angular 2 RC 5 global provider

How can i have a global provider that is initialized just once. So i have the following provider @Injectable() export class ApiRequest { http: Http; constructor(@Inject(Http) http) { console.log('Test'); } } And then a shared…
keepwalking
  • 2,644
  • 6
  • 28
  • 63