- Node
- npm or yarn.
Angular library providing wrappers for dom types.
npm install ngx-dom-wrappers
or
yarn add ngx-dom-wrappers
- Import
DomWrappersModule
inAppModule
orCoreModule
of your application.
AppModule
@NgModule({
imports: [
// Other imports
DomWrappersModule
// Other imports
],
})
export class AppModule { }
CoreModule
@NgModule({
imports: [
// Other imports
DomWrappersModule
// Other imports
],
exports: [
// Other exports
DomWrappersModule
// Other exports
],
})
export class CoreModule { }
- Use wrappers in your code
import { WINDOW, LOCAL_STORAGE, SESSION_STORAGE } from 'ngx-dom-wrappers'
constructor(
@Inject(WINDOW) windowWrapper: any,
@Inject(LOCAL_STORAGE) localStorageWrapper: any,
@Inject(SESSION_STORAGE) sessionStorageWrapper: any,
) {
const windowObject = windowWrapper as Window
if (windowObject) {
// Your code
}
}
- Docs: https://spaier.github.io/ngx-dom-wrappers
- CoreModule: https://angular.io/guide/styleguide#core-feature-module
MIT