Skip to content

Commit 10df2ad

Browse files
committed
fix: fixed an issue with aot compilation and service factory
1 parent 69c3713 commit 10df2ad

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/xivapi-client.module.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { ModuleWithProviders, NgModule } from '@angular/core';
1+
import { InjectionToken, ModuleWithProviders, NgModule } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33
import { XivapiService } from './xivapi.service';
44
import { HttpClient, HttpClientModule } from '@angular/common/http';
55
import { XivapiServiceFactory } from './xivapi-service-factory';
66

7+
export const XIVAPI_KEY: InjectionToken<string> = new InjectionToken('XIVAPI_KEY');
8+
79
@NgModule({
810
imports: [
911
CommonModule,
@@ -17,10 +19,14 @@ export class XivapiClientModule {
1719
return {
1820
ngModule: XivapiClientModule,
1921
providers: [
22+
{
23+
provide: XIVAPI_KEY,
24+
useValue: key
25+
},
2026
{
2127
provide: XivapiService,
2228
useFactory: XivapiServiceFactory,
23-
deps: [key, HttpClient]
29+
deps: [XIVAPI_KEY, HttpClient]
2430
}
2531
]
2632
};

src/xivapi.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Inject, Injectable, Optional } from '@angular/core';
1+
import { Inject, Injectable } from '@angular/core';
22
import { HttpClient, HttpParams } from '@angular/common/http';
33
import { Observable } from 'rxjs';
44
import {
@@ -12,6 +12,7 @@ import {
1212
XivapiSearchOptions
1313
} from './model';
1414
import { CharacterResponse, CharacterVerification } from './model/schema/character';
15+
import { XIVAPI_KEY } from './xivapi-client.module';
1516

1617
@Injectable()
1718
export class XivapiService {
@@ -21,7 +22,7 @@ export class XivapiService {
2122
*/
2223
public static readonly API_BASE_URL: string = 'https://xivapi.com';
2324

24-
constructor(@Inject('XIVAPI_KEY') protected readonly apiKey: string, private http: HttpClient) {
25+
constructor(@Inject(XIVAPI_KEY) protected readonly apiKey: string, private http: HttpClient) {
2526
}
2627

2728
/**

0 commit comments

Comments
 (0)