Created
January 15, 2017 09:04
-
-
Save jordic/6126cb839e0c773b4343a481fa326e39 to your computer and use it in GitHub Desktop.
Angular module with configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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