ionic router update

This commit is contained in:
Adam Bradley
2015-08-21 23:04:23 -05:00
parent 5b5e32ded5
commit 26e0117a3f
18 changed files with 259 additions and 681 deletions

View File

@@ -1,6 +1,6 @@
import {Component, View, bootstrap, ElementRef, NgZone, bind, DynamicComponentLoader, Injector} from 'angular2/angular2';
import {routerInjectables, HashLocationStrategy, LocationStrategy, Router} from 'angular2/router';
import {IonicRouter} from '../../routing/router';
import {IonicConfig} from '../../config/config';
import {Platform} from '../../platform/platform';
import * as util from '../../util/util';
@@ -19,8 +19,6 @@ export class IonicApp {
// Our component registry map
this.components = {};
this._activeViewId = null;
}
load(appRef) {
@@ -54,17 +52,6 @@ export class IonicApp {
this._zone.run(fn);
}
stateChange(type, activeView) {
if (this._activeViewId !== activeView.id) {
this.router.stateChange(type, activeView);
this._activeViewId = activeView.id;
}
}
stateClear() {
this.router.stateClear();
}
/**
* Register a known component with a key, for easy lookups later.
*/
@@ -175,7 +162,7 @@ class RootAnchor {
}
}
export function ionicBootstrap(rootComponentType, config, router) {
export function ionicBootstrap(rootComponentType, config) {
return new Promise(resolve => {
try {
// get the user config, or create one if wasn't passed in
@@ -197,15 +184,6 @@ export function ionicBootstrap(rootComponentType, config, router) {
// prepare the ready promise to fire....when ready
Platform.prepareReady(config);
// setup router
if (typeof router !== IonicRouter) {
router = new IonicRouter(router);
}
router.app(app);
// TODO: don't wire these together
app.router = router;
// TODO: probs need a better way to inject global injectables
let actionMenu = new ActionMenu(app, config);
let modal = new Modal(app, config);
@@ -215,10 +193,11 @@ export function ionicBootstrap(rootComponentType, config, router) {
let appBindings = Injector.resolve([
bind(IonicApp).toValue(app),
bind(IonicConfig).toValue(config),
bind(IonicRouter).toValue(router),
bind(ActionMenu).toValue(actionMenu),
bind(Modal).toValue(modal),
bind(Popup).toValue(popup)
bind(Popup).toValue(popup),
routerInjectables,
bind(LocationStrategy).toClass(HashLocationStrategy)
]);
bootstrap(rootComponentType, appBindings).then(appRef => {
@@ -240,10 +219,7 @@ export function ionicBootstrap(rootComponentType, config, router) {
console.error(err)
});
router.load(window, app, config).then(() => {
// resolve that the app has loaded
resolve(app);
});
resolve(app);
}).catch(err => {
console.error('ionicBootstrap', err);