Skip to content

Instantly share code, notes, and snippets.

@LayZeeDK
Last active January 20, 2019 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LayZeeDK/0dc28b2b23884778d0ae96f014b705f2 to your computer and use it in GitHub Desktop.
Save LayZeeDK/0dc28b2b23884778d0ae96f014b705f2 to your computer and use it in GitHub Desktop.
Modern injection token with value factory
import { InjectionToken } from '@angular/core';
export const isInternetExplorer11Token: InjectionToken<boolean> =
new InjectionToken('Internet Explorer 11 flag', {
factory: (): boolean =>
/Trident\/7\.0.+rv:11\.0/.test(navigator.userAgent),
providedIn: 'root',
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment