Skip to content

Instantly share code, notes, and snippets.

@jordic
Created January 15, 2017 09:04
Show Gist options
  • Save jordic/6126cb839e0c773b4343a481fa326e39 to your computer and use it in GitHub Desktop.
Save jordic/6126cb839e0c773b4343a481fa326e39 to your computer and use it in GitHub Desktop.
Angular module with configuration
import { NgModule, Injectable, ModuleWithProviders,
OpaqueToken, Inject } from '@angular/core';
import { Store } from '@ngrx/store';
import { WindowRef } from '../browser';
const GJS_CLIENT = 'https://apis.google.com/js/client.js';
const SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly'];
export let CLIENT_ID = new OpaqueToken('sheets.config');
@Injectable()
export class GoogleSheet {
constructor(
@Inject(CLIENT_ID) private cid: string,
private win: WindowRef) {
console.log('Module instantiated with: ', cid);
}
}
@NgModule({})
export class DriveModule {
static forRoot(clientId): ModuleWithProviders {
return {
ngModule: DriveModule,
providers: [
GoogleSheet,
{provide: CLIENT_ID, useValue: clientId }
],
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment