0

Supposedly I have a web component and a nativescript component. Let's say app.component.ts.

Now, web component supposed to have different class variables than nativescript component. How am I supposed to have a 1 component class that will compile different class variables.

The docs is clear on how to do partial differences in regards to class methods, but not with class variables and dependency injection.

Is creating .tns file only the option in this kind of scenario?

Thanks!

iamjc015
  • 2,127
  • 6
  • 25
  • 61

1 Answers1

0

Yes, at some point you would need one or a few tns specific files in your project. You can not avoid them because your components on web and mobile are entirely different.

If you want to directly inject any dependency into your component's constructor, then yes you might have to go with tns component.

Or to avoid having too many tns components you could write a tns service which would wrap platform specific stuffs. Then probably call the service from your component.

Manoj
  • 21,753
  • 3
  • 20
  • 41