The code below is not complete, but gives you an idea of ββthe direction in which you should move. This is a modified version of the template code created for you whenever you use ionic-clito create a new application.
app/ services. , AService app/services/a-service.ts. app.ts, ionicBootstrap() . constructor() MyApp.
$scope $rootScope, app-wide. (, UserData), , .
Ionic 2 Conference Application, Ionic 2 . , , .
import { Component } from "@angular/core";
import { ionicBootstrap, Platform, Nav } from "ionic-angular";
import { AService } from "./services/a-service";
import { BService } from "./services/b-service";
import { CService } from "./services/c-service";
import { UserData } from "./providers/user-data";
import { HomePage } from "./pages/home/home";
@Component({
templateUrl: "build/app.html"
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage: any = HomePage;
pages: Array<{ title: string, component: any }>;
constructor(
private platform: Platform,
private aSvc: AService,
private bSvc: BService,
private cSvc: CService,
private userData: UserData
) {
this.initializeApp();
this.pages = [
{ title: "Home Page", component: HomePage }
];
}
initializeApp() {
this.platform.ready().then(() => {
bSvc.setOnline(true);
});
}
openPage(page) {
this.nav.setRoot(page.component);
}
}
ionicBootstrap(MyApp, [AService, BService, CService, UserData]);