Skip to content

Instantly share code, notes, and snippets.

View chsami's full-sized avatar

chsami chsami

View GitHub Profile
<input type="text" />
<div tabindex="0"></div>
<div tabindex="0"></div>
<input type="text" />
export class MapModule {
//create a static function with the mapConfig as a parameter
static forRoot(mapConfig: IMapsConfig): ModuleWithProviders {
return {
ngModule: MapModule,
//We provide a MapsConfig InjectionToken, which we later can use in our service to use
providers: [ {provide: MapsConfig, useValue: mapConfig} ]
};
}
}
export class MapModule {
//create a static function with the mapConfig as a parameter
static forRoot(mapConfig: IMapsConfig): ModuleWithProviders {
return {
ngModule: MapModule,
//We provide a MapsConfig InjectionToken, which we later can use in our service to use
providers: [ {provide: MapsConfig, useValue: mapConfig} ]
};
}
}
//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(
export interface IMapsConfig {
key: string;
}
export class MapModule {
static forRoot(mapConfig: IMapsConfig): ModuleWithProviders {
return {
ngModule: MapModule,
providers: [ {provide: MapsConfig, useValue: mapConfig} ]
}
}
}
@NgModule({
imports: [
MapModule.forRoot({
key: 'mykeyId'
})
],
})
let cache$: Observable<any>;
cache$ = this.situationService.getSituations(this.id).shareReplay(1);
cache$.subscribe((situations: ISituation[]) => {
this.situations = situations;
});
cache$.subscribe((situations: ISituation[]) => {
var marker = google.maps.Marker();
<head>
<link rel="import" href="/path/to/some/import.html">
</head>