File

libs/fe-utilities/src/lib/browser/window.service.ts

Description

Define a service that exposes the native window object

Index

Accessors

Accessors

nativeWindow
getnativeWindow()

Return a function that returns the native window object

Returns : Window
import { Injectable } from '@angular/core';


/**
 * Return the native window object
 *
 * @returns The native window object
 */
const realWindow = (): Window => window;


/**
 * Define a service that exposes the native window object
 */
@Injectable({ providedIn: 'root' })
export class TsWindowService {
  /**
   * Return a function that returns the native window object
   *
   * @returns The function that returns the native window object
   */
  public get nativeWindow(): Window {
    return realWindow();
  }
}

result-matching ""

    No results matching ""