Last active
October 27, 2017 14:31
-
-
Save rdemetrescu/2cbb0255f2077c30921810bff766de3c to your computer and use it in GitHub Desktop.
Issues with child routers and view router with layout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <require from="./nav-bar"></require> | |
| <h1>Main router</h1> | |
| <div> | |
| <label> | |
| <input type="checkbox" checked.bind="useLayout"> | |
| Use custom layout | |
| </label> | |
| </div> | |
| <nav-bar router.bind="router"></nav-bar> | |
| <router-view if.bind="!useLayout"></router-view> | |
| <router-view layout-view="layout.html" if.bind="useLayout"></router-view> | |
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class App { | |
| constructor() { | |
| this.useLayout = false; | |
| } | |
| configureRouter(config, router) { | |
| this.router = router; | |
| config.title = 'Aurelia'; | |
| config.map([ | |
| { route: ['child1', ''], name: 'child1', moduleId: './child1', nav: true, title: 'Child 1' }, | |
| { route: 'child2', name: 'child2', moduleId: './child2', nav: true, title: 'Child 2' } | |
| ]); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <require from="./nav-bar"></require> | |
| <div slot="myslot"> | |
| <h2>Child 1</h2> | |
| <nav-bar router.bind="router"></nav-bar> | |
| <router-view></router-view> | |
| </div> | |
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class Child1 { | |
| configureRouter(config, router) { | |
| this.router = router; | |
| config.map([ | |
| { route: ['page1', ''], name: 'page1', moduleId: './page1', nav: true, title: 'page 1' }, | |
| { route: 'page2', name: 'page2', moduleId: './page2', nav: true, title: 'page 2' } | |
| ]); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <require from="./nav-bar"></require> | |
| <div slot="myslot"> | |
| <h2>Child 2</h2> | |
| <nav-bar router.bind="router"></nav-bar> | |
| <router-view></router-view> | |
| </div> | |
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class Child2 { | |
| configureRouter(config, router) { | |
| this.router = router; | |
| config.map([ | |
| { route: ['page3', ''], name: 'page3', moduleId: './page3', nav: true, title: 'page 3' }, | |
| { route: 'page4', name: 'page4', moduleId: './page4', nav: true, title: 'page 4' } | |
| ]); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html> | |
| <head> | |
| <title>Aurelia</title> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <link rel="stylesheet" href="styles.css"> | |
| </head> | |
| <body aurelia-app> | |
| <h1>Loading...</h1> | |
| <script src="https://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script> | |
| <script src="https://jdanyow.github.io/rjs-bundle/config.js"></script> | |
| <script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script> | |
| <script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script> | |
| <script> | |
| require(['aurelia-bootstrapper']); | |
| </script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <div style="border: 5px dashed red; padding: 20px"> | |
| <p>inside layout.html</p> | |
| <slot name="myslot"></slot> | |
| </div> | |
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <h3>Page 1</h3> | |
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class Page1 { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <h3>Page 2</h3> | |
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class Page2 { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <h3>Page 3</h3> | |
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class Page3 { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template> | |
| <h3>Page 4</h3> | |
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class Page4 { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .active { color: red; font-weight:bold; }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment