File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 1- import { ModuleWithProviders , NgModule } from '@angular/core' ;
1+ import { InjectionToken , ModuleWithProviders , NgModule } from '@angular/core' ;
22import { CommonModule } from '@angular/common' ;
33import { XivapiService } from './xivapi.service' ;
44import { HttpClient , HttpClientModule } from '@angular/common/http' ;
55import { 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 } ;
Original file line number Diff line number Diff line change 1- import { Inject , Injectable , Optional } from '@angular/core' ;
1+ import { Inject , Injectable } from '@angular/core' ;
22import { HttpClient , HttpParams } from '@angular/common/http' ;
33import { Observable } from 'rxjs' ;
44import {
@@ -12,6 +12,7 @@ import {
1212 XivapiSearchOptions
1313} from './model' ;
1414import { CharacterResponse , CharacterVerification } from './model/schema/character' ;
15+ import { XIVAPI_KEY } from './xivapi-client.module' ;
1516
1617@Injectable ( )
1718export 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 /**
You can’t perform that action at this time.
0 commit comments