In a provider you could not access to components like navcontroller, loadingcontroller etc. maybe it’s the same for the platform. This “force” you to have a nice separation between presentation and logic.
constructor(public platform: Platform) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
console.log(“Platform is ready”);
});
}
Hi Sathyesh.
I made a duplicate of my service and removed portions of it until it worked.
The following was the problem:
static get parameters() {
return [[Http]];
}
With that in the Provider, the Platform.ready was not working.
However, without that in there, I now get an error: ORIGINAL EXCEPTION: No provider for NavController!
Here is the provider:
import {Page, NavController, Platform} from ‘ionic-angular’;
import {Injectable, Component} from ‘@angular/core’;
import {Http} from ‘@angular/http’;
@Injectable()
export class Test {
// static get parameters() {
//return [[Http]];
//}
constructor(public nav: NavController, public platform: Platform) {
platform.ready().then(() => {
console.log("Platform is ready");
});
}
}
Unless you have any thoughts, I might need to create a new post on how to use the Platform.ready AND NavController / static get parameters
Thanks for that. There a few options I will try including getActiveNav()
I will also consider not using it at all
That said, you did not get the error when you tried?
I am gone now for most of the day - thanks again!