Skip to content

Instantly share code, notes, and snippets.

@chsami
Created December 25, 2018 14:39
Show Gist options
  • Save chsami/a854ff2e25b13a844919f35c0a2b989e to your computer and use it in GitHub Desktop.
Save chsami/a854ff2e25b13a844919f35c0a2b989e to your computer and use it in GitHub Desktop.
//Use the InjectionToken for the mapsConfig, this can be later used to inject it with DI
export const MapsConfig = new InjectionToken<IMapsConfig>('MAPS_CONFIG');
@Injectable({
providedIn: MapModule
})
export class MapService {
private _key: string;
constructor(
@Optional() @Inject(MapsConfig) config: IMapsConfig = null
) {
if (config) {
this._key = config.key;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment