diff --git a/ionic/components/app/test/sink/index.js b/ionic/components/app/test/sink/index.js index 3ebd56340e..bde66e9807 100644 --- a/ionic/components/app/test/sink/index.js +++ b/ionic/components/app/test/sink/index.js @@ -4,8 +4,6 @@ import {Descendant} from 'angular2/src/core/annotations_impl/visibility'; import {View} from 'angular2/src/core/annotations_impl/view'; import {Query} from 'angular2/src/core/annotations_impl/di'; -console.log(Query, QueryList); - import {Ionic, Nav, ViewContainer, Aside, List, Item, Content} from 'ionic/ionic'; import {ButtonPage} from './pages/button' @@ -23,19 +21,17 @@ import {SlidePage} from './pages/slides' import {ActionMenuPage} from './pages/action-menu' import {ModalPage} from './pages/modal' -console.log('Loaded', Nav, NgFor, NgIf, Aside, List, ViewContainer, Item, Content); +console.log('Loaded', Nav, NgFor, NgIf, Aside, List, Item, Content); @Component({ selector: 'ion-view', }) @View({ templateUrl: 'main.html', - directives: [Nav, NgFor, NgIf, Aside, List, ViewContainer, Item, Content] + directives: [Nav, NgFor, NgIf, Aside, List, Item, Content] }) class IonicApp { constructor(elementRef: ElementRef) {//, @Query(Aside) nav: QueryList) {//, @Descendant() aside: Aside) { - Ionic.setRootElementRef(elementRef); - this.components = [ { title: 'Navigation', component: NavPage }, { title: 'Buttons', component: ButtonPage }, @@ -58,11 +54,8 @@ class IonicApp { openPage(aside, component) { aside.close(); - window.nav.clear().then(() => { - window.nav.push(component.component, {}, { - animate: false - }); - }) + + window.nav.setItems([component.component]); } } diff --git a/ionic/components/nav/nav-controller.js b/ionic/components/nav/nav-controller.js index 43bb4960e6..235117189c 100644 --- a/ionic/components/nav/nav-controller.js +++ b/ionic/components/nav/nav-controller.js @@ -5,6 +5,13 @@ export class NavController { this._nav = nav; } + /** + * Set the history stack to match the list of component items. + */ + setItems(items) { + return this._nav.setItems(items); + } + /** * Clear the history stack. */ diff --git a/ionic/components/view/view-controller.js b/ionic/components/view/view-controller.js index bce8f67cf3..9f5fa178e5 100644 --- a/ionic/components/view/view-controller.js +++ b/ionic/components/view/view-controller.js @@ -417,6 +417,34 @@ export class ViewController { return this.items.length; } + /** + * Set the item stack to reflect the given component classes. + */ + setItems(components) { + // Pop all of the current items + this.clear(); + + + // Then, change the root + + let leavingItem = this.getActive() || new ViewItem(); + leavingItem.shouldDestroy = true; + leavingItem.shouldCache = false; + leavingItem.willUnload(); + + this.transitionComplete(); + + for(let c of components) { + this.push(c, { + animate: false + }) + } + } + + /** + * Pops off all the trailing items, but leaves the root. + * To change the root, call setRoot with the root component. + */ clear() { let pops = []; for (let item of this.items) {