📜  @Inject(PLATFORM_ID)private platformId - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:26.084000             🧑  作者: Mango

代码示例1
component.ts

import { Component, Inject } from '@angular/core';
import { PLATFORM_ID } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';

@Component({
  selector: 'mySpecial',
  templateUrl: './mySpecial.component.html'
})
export class MySpecialComponent {
  isBrowser: boolean;

  constructor( @Inject(PLATFORM_ID) platformId: Object) {
    this.isBrowser = isPlatformBrowser(platformId);
  }
}
component.html

Hello World

Steak Pizza Tacos