0

I have a super class (component) and a few child classes (components) and I need to check PLATFORM_ID in each of them (something like below):

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

export class SliderComponent implements OnInit {
  ...
  constructor(@Inject(PLATFORM_ID) private platformId: Object) {}
  ...
}

//Child
export class ProductsComponent extends SliderComponent implements OnInit {
  ...
  constructor(private pls: ProductsService) {
    super(); // <-- I don't want to pass smth. here because I'll need to import add. modules
  }
  ...
}

Could I implement the inheritance without importing Inject, PLATFORM_ID, etc.?

Andrew Halil
  • 1,107
  • 15
  • 14
  • 19
mark
  • 117
  • 8
  • Maybe this is a solution for you? https://stackoverflow.com/questions/42461852/inject-a-service-manually/42462579#42462579 – MikeOne Oct 22 '21 at 11:19

0 Answers0