Why I got this warning by tslint?
Package name: io.ionic.starter
[18:37:16] tslint: s:/IonicProject/VerificheNawi/src/pages/home/home.ts, line: 14
Property 'platform' is declared but never used.
L14: constructor(public navCtrl: NavController, private platform: Platform, public splash: SplashScreen) {
L15: platform.ready().then(() => {
As you can see, L15 use platform... I wonder if there is something I didn't yet understood about injection.
The problem is the line number 14. So try with this:
constructor(platform: Platform, public navCtrl: NavController, public splash: SplashScreen) {
by omitting the private
keyword for the platform in the constructor, we're telling Typescript not to create a property for it, in this component.
Why? Since you're using the platform like this: platform.ready...
you're not using the property from the component, but the parameter from the constructor.
So as I see it, you could fix that in two ways:
private
keyword next to the platform, in the constructor
, in order to not create a property in the component, and just use the platform
parameter.platform.ready().then(...)
by this.platform.ready().then(..)
to use the property from the component (by using the this
keyword).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With