diff --git a/ionic/components/nav/nav-router.ts b/ionic/components/nav/nav-router.ts index 77bc9dcb81..b869ad7648 100644 --- a/ionic/components/nav/nav-router.ts +++ b/ionic/components/nav/nav-router.ts @@ -74,22 +74,22 @@ export class NavRouter extends RouterOutlet { // viewCtrl is Ionic's ViewController class, which has the properties "componentType" and "params" // only do an update if there's an actual view change - if (!viewCtrl || this._activeViewId === viewCtrl.id) return; - this._activeViewId = viewCtrl.id; + // if (!viewCtrl || this._activeViewId === viewCtrl.id) return; + // this._activeViewId = viewCtrl.id; - // get the best PathRecognizer for this view's componentType - let pathRecognizer = this.getPathRecognizerByComponent(viewCtrl.componentType); - if (pathRecognizer) { + // // get the best PathRecognizer for this view's componentType + // let pathRecognizer = this.getPathRecognizerByComponent(viewCtrl.componentType); + // if (pathRecognizer) { - // generate a componentInstruction from the view's PathRecognizer and params - let componentInstruction = pathRecognizer.generate(viewCtrl.params.data); + // // generate a componentInstruction from the view's PathRecognizer and params + // let componentInstruction = pathRecognizer.generate(viewCtrl.params.data); - // create an Instruction from the componentInstruction - let instruction = new Instruction(componentInstruction, null); + // // create an Instruction from the componentInstruction + // let instruction = new Instruction(componentInstruction, null); - // update the browser's URL - this._parentRouter.navigateInstruction(instruction); - } + // // update the browser's URL + // this._parentRouter.navigateInstruction(instruction); + // } } /** diff --git a/ionic/components/nav/nav.ts b/ionic/components/nav/nav.ts index db8a5d36d1..a2391a5634 100644 --- a/ionic/components/nav/nav.ts +++ b/ionic/components/nav/nav.ts @@ -181,12 +181,12 @@ export class Nav extends NavController { // this gets or creates the Pane which similar nav items live in // Nav items with just a navbar/content would all use the same Pane // Tabs and view's without a navbar would get a different Panes - let structure = this.inspectStructure(hostProtoViewRef); + let structure = this.getStructure(hostProtoViewRef); if (structure.tabs) { // the component being loaded is an // Tabs is essentially a pane, cuz it has its own navbar and content containers - let contentContainerRef = this.viewMngr.getViewContainer(this.anchorElementRef()); + let contentContainerRef = this._viewManager.getViewContainer(this.anchorElementRef()); let viewComponetRef = this.createViewComponetRef(componentType, hostProtoViewRef, contentContainerRef, this.getBindings(viewCtrl)); viewComponetRef.instance._paneView = true; @@ -308,32 +308,40 @@ export class Nav extends NavController { * @param {TODO} componentProtoViewRef TODO * @return {TODO} TODO */ - inspectStructure(componentProtoViewRef) { - let navbar = false; - let tabs = false; - let key = '_'; + getStructure(componentProtoViewRef) { + let templateCmds = componentProtoViewRef._protoView.templateCmds; + let compiledTemplateData, directives; + let i, ii, j, jj, k, kk; - componentProtoViewRef._protoView.elementBinders.forEach(rootElementBinder => { - if (!rootElementBinder.componentDirective || !rootElementBinder.nestedProtoView) return; + for (i = 0, ii = templateCmds.length; i < ii; i++) { + if (templateCmds[i].template) { + compiledTemplateData = templateCmds[i].template.getData(templateCmds[i].templateId); + if (compiledTemplateData) { + for (j = 0, jj = compiledTemplateData.commands.length; j < jj; j++) { + directives = compiledTemplateData.commands[j].directives; + + if (directives && (kk = directives.length)) { + + for (k = 0; k < kk; k++) { + + if (directives[k].name == 'NavbarTemplate') { + return { navbar: true }; + } + + if (directives[k].name == 'Tabs') { + return { tabs: true }; + } + + } - rootElementBinder.nestedProtoView.elementBinders.forEach(nestedElementBinder => { - if ( isComponent(nestedElementBinder, 'Tabs') ) { - tabs = true; - } - if (!nestedElementBinder.componentDirective && nestedElementBinder.nestedProtoView) { - nestedElementBinder.nestedProtoView.elementBinders.forEach(templatedElementBinder => { - if ( isComponent(templatedElementBinder, 'Navbar') ) { - navbar = true; } - }); - } - }); - }); - return { - navbar, - tabs - }; + } + } + } + } + + return {}; } } diff --git a/ionic/components/tabs/test/advanced/index.ts b/ionic/components/tabs/test/advanced/index.ts index 1926ef7b49..e414b6680a 100644 --- a/ionic/components/tabs/test/advanced/index.ts +++ b/ionic/components/tabs/test/advanced/index.ts @@ -186,7 +186,7 @@ class Tab3Page1 {} @App() @RouteConfig([ - { path: '/', component: SignIn, as: 'signin' }, - { path: '/tabs', component: TabsPage, as: 'tabs' }, + { path: '/', component: SignIn, as: 'Signin' }, + { path: '/tabs', component: TabsPage, as: 'Tabs' }, ]) class E2EApp {}