Questions tagged [injectable]
121 questions
0
votes
2 answers
How to use service in Component?
When I inject UserService then component it doesn't appear
When I remove service from component then component works fine
providers in @NgModule
providers: [
UserService,
{
provide:AuthServiceConfig,
useFactory:…

Amir Mujtaba
- 1
- 2
0
votes
1 answer
use Injectable service insight another Injectable service angular 5
I am struggling to use Injectable service insight another Injectable service in angular 5
Here is my crudService.ts :
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable()
export class…

Andrei
- 341
- 7
- 23
0
votes
1 answer
No provider for BaseService class
I have project on the Angular 6. Some of my services extend base classes. Base classes are regular TypeScript classes without the @Injectable decorator. When I try to run the app I'm getting the error:
NullInjectorError: No provider for…

WeekendMan
- 561
- 1
- 10
- 25
0
votes
1 answer
Unit Test of Service with HttpClient parameter raise "TypeError: _this.handler.handle is not a function"
I created a class that is an injectable service and I would like to test the functions that return an Observable object.
As soon as I try to test a function like this, I get the following error:
TypeError: _this.handler.handle is not a function
How…

Algorys
- 1,710
- 2
- 25
- 52
0
votes
1 answer
ionic: cyclical dependency and cannot resolve all parameters for
I have a component (ItemDetailsPage) that is importing a helper service
import { Helper } from './../../app/Helper';
and in the constructor I have
constructor(public viewCtrl: ViewController, public navCtrl: NavController, public navParams:…

Amos
- 1,321
- 2
- 23
- 44
0
votes
1 answer
javafx project that has an fxml document that won't let me inject a label into my controller
I created a JavaFX project. Here is what it looks like:
In SceneBuilder I created a BorderPane with one label with the id label.
In my SampleController I use this Label named label:
Label label;
public SampleController() {
…

user3606066
- 21
- 5
0
votes
2 answers
Angular 5: Run Constructor before beeing injected
I have a file with global variables:
@Injectable()
export class Globals {
public baseURL:string;
public loginURL:string;
public proxyURL:string;
public servicesURL:string;
constructor(platformLocation: PlatformLocation) {
this.baseURL…

NDDT
- 445
- 1
- 10
- 27
0
votes
3 answers
Angular cant inject HttpClient getting 'Can't resolve all parameters for CustomerService' error
I have a customerService where im trying to inject httpClient. Error is happening on the line where i commented //error happens on this line. Everything works until i try to inject httpClient into my service.
Error message is :
`compiler.js:485…

kkdeveloper7
- 497
- 2
- 11
- 25
0
votes
1 answer
Angular HttpClient and Services
Ok so a quick question. I am seeing a lot of implementations whereby developers implement an api request in the component directly since HttpClient is injectable. Is this the way to go or is it cleaner (from a purist point of view) to have a proper…

Metrophobe
- 83
- 1
- 9
0
votes
1 answer
How to reference helper methods methods using 'this' from an Injectable?
An Injectable Class's 'this' is referencing the injected component's this.
Wanted to use injectable to abstract code from the component. But when I use 'this' to reference other methods in a parent method in the @Injectable class and then try to use…

jamie
- 690
- 7
- 18
0
votes
2 answers
Calling methods between components in angular using service not working
I am trying to call a method in one component from other component using injectable service
My first component (I'm calling method in other component from this component)
bottombar.component.ts
import { Component, ElementRef, OnInit, ViewChild,…

Yeshwanth
- 70
- 8
0
votes
1 answer
EXCEPTION: No provider found for Component
I have a custom form and custom input.
I am trying to inject the custom form into the custom input.
It works when the input is a direct child of the form, however, when I have a component between them, it throws an exception.
this works:
The…

Jonathan
- 4,724
- 7
- 45
- 65
0
votes
2 answers
Angular2 @Injectable not working
I have an @Injectable class with a get-function in Service.ts create. This function should return one Array and also get any array. But it returns null. If I write this directly in a @Component, then it does get the array. What am I doing wrong?…

ran
- 1
- 3
0
votes
1 answer
Detecting changes to service stub using TestBed
This is the test example for a Component with a Service using stubs provided in the angular2 documentation.
When I am trying to build it out and run it, I find that the component does not pick up the changes for the second test case. I always see…

vamsiampolu
- 6,328
- 19
- 82
- 183
0
votes
1 answer
How do I Initialize Injectable variable using a service
I am using Ionic2 Storage to store user access_token credentials when a user logs in.
When the user tries to access a backend api I need to supply the access_token to a REST client.
I have created service using hBoylan's ng2-http package
Initially…

Schwoebel
- 216
- 1
- 4
- 19