Angular2-jwt: No provider for AuthHttp!

Created on 24 May 2016  路  1Comment  路  Source: auth0/angular2-jwt

I know for sure that i'm doing some wrong in doing the imports or in the way doing the dependency injection.

I have LoginService class where i send the login parameters to the server. When i remove AuthHttp from imports, the login page is shown. but, the constructor argument injection failed since i have reference to authHttp parameter. But, when i add AuthHttp to the import as shown below, it throws the error

No Provider for AuthHttp

import {Injectable} from 'angular2/core';
import {IUser, User} from '../models';
import {AUTH_PROVIDERS,AuthHttp,JwtHelper} from 'angular2-jwt'
import {Appsettings} from '../app.settings'


@Injectable()
export class LoginService {

    private _user : IUser = null;

    private LOGIN_API_URL : string = "/users/login"

    private jwtHelper : JwtHelper = new JwtHelper();

    constructor(private authHttp : AuthHttp) {          
    }


ORIGINAL EXCEPTION: No provider for AuthHttp!
ORIGINAL STACKTRACE:
Error: DI Exception
    at NoProviderError.BaseException [as constructor] (http://localhost:3000/vendor.bundle.js:1079:24)
    at NoProviderError.AbstractProviderError [as constructor] (http://localhost:3000/vendor.bundle.js:9964:17)

I would like to know how to inject AuthHttp with my `AuthConfig object into my service implementations?

>All comments

Have you looked through this? https://angular.io/docs/ts/latest/cookbook/dependency-injection.html#!#nested-dependencies

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kolkov picture kolkov  路  3Comments

jaumard picture jaumard  路  5Comments

mahendra2125 picture mahendra2125  路  4Comments

ciesielskico picture ciesielskico  路  5Comments

fabiodomingues picture fabiodomingues  路  5Comments