Wednesday, April 8, 2020

@Inject(PLATFORM_ID) in Angular 5

Assuming this...

import { PLATFORM_ID } from "@angular/core";
import { isPlatformBrowser } from "@angular/common";

 
 

...then page 464 of "ASP.NET Core 2 and Angular 5" by Valerio De Sanctis suggests you could have:

constructor (@Inject(PLATFORM_ID) private x: any) {
   if (!isPlatformBrowser(x)) {

 
 

isPlatformBrowser just returns true of false.

No comments:

Post a Comment