Globals
A small useful piece for globals seperation.
Installation
npm i -P @angeeks/globals
🚧 Usage
import { GlobalsModule } from '@angkees/globals';
@NgModule({
imports: [
...,
GlobalsModule
]
})
That's it, now you can use globals in as injectables.
import { Globals } from '@angkees/globals';
class AppComponent {
constructor(g: Globals) {
g.window.open('http://google.com', 'blank');
g.console.log(g.document.body);
g.localStorage.set('key', 'value');
}
}
Advanced Usage
🚧 Inject customed symbols
import { GlobalsModule, windowToken } from '@angkees/g';
@NgModule({
imports: [
...,
GlobalsModule
],
providers: [
{ provide: windowToken, useValue: { window: 'for test' } }
]
})