Angular2-jwt: Missing .metadata.json for angular 2 AOT compiler?

Created on 21 Dec 2016  路  4Comments  路  Source: auth0/angular2-jwt

ERROR in Error encountered resolving symbol values statically. Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler (position 79:22 in the original .ts file), resolving symbol AUTH_PROVIDERS...

I think it is because of ng2-bingmaps did not contain the required *.metadata.json files for each .d.ts file.

bug

Most helpful comment

Also, Angular will complain about them trying to use a lambda function as the factory in AUTH_PROVIDERS.

The code still seems to work fine even though there is an error, but I worked around to get rid of the error by providing my own AUTH_PROVIDERS in my AppModule file with:

import { Http, HttpModule, RequestOptions } from '@angular/http';
import { AuthHttp, AuthConfig } from 'angular2-jwt';

export function AuthHttpFactory (http: Http, options: RequestOptions) {
    return new AuthHttp(new AuthConfig(), http, options);
}

and in the module providers:

providers: [
    {
      provide: AuthHttp,
      deps: [Http, RequestOptions],
      useFactory: AuthHttpFactory
    }
  ]

All 4 comments

+1
providers: [
AUTH_PROVIDERS <--------ng serve error!!!!
],

I also got this error with angular-cli 1.0.0-beta.24 and angular 2.3.1.

AUTH_PROVIDERS don't import providers
and yourComponent.ts mark "// private authHttp: AuthHttp,"

it's just only login logout!!! XD

Also, Angular will complain about them trying to use a lambda function as the factory in AUTH_PROVIDERS.

The code still seems to work fine even though there is an error, but I worked around to get rid of the error by providing my own AUTH_PROVIDERS in my AppModule file with:

import { Http, HttpModule, RequestOptions } from '@angular/http';
import { AuthHttp, AuthConfig } from 'angular2-jwt';

export function AuthHttpFactory (http: Http, options: RequestOptions) {
    return new AuthHttp(new AuthConfig(), http, options);
}

and in the module providers:

providers: [
    {
      provide: AuthHttp,
      deps: [Http, RequestOptions],
      useFactory: AuthHttpFactory
    }
  ]
Was this page helpful?
0 / 5 - 0 ratings