-
-
Save BruceL33t/73c1b4822a6544c6316da8bd55d6abea to your computer and use it in GitHub Desktop.
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> | |
<style> | |
.active a { color: red; font-weight: bold; } | |
</style> | |
<ul> | |
<li > | |
<a href="#viewmodel-with-subrouter/shared-parent/child-a">child a</a> | |
</li> | |
<li > | |
<a href="#viewmodel-with-subrouter/shared-parent/child-b">child b</a> | |
</li> | |
</ul> | |
<router-view></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 { | |
message = 'Hello World!'; | |
configureRouter(config, router){ | |
config.title = 'Aurelia'; | |
config.map([ | |
{ route: ['','viewmodel-with-subrouter'], moduleId: './viewmodel-with-subrouter' , nav: true, title: 'viewmodel-with-subrouter' }, | |
]); | |
this.router = router; | |
} | |
} |
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 slot="somename" class="child"> | |
Child A | |
</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
import {inject} from 'aurelia-framework'; | |
import {SharedState} from './shared-state'; | |
import {EventAggregator} from 'aurelia-event-aggregator'; | |
@inject(SharedState,EventAggregator) | |
export class ChildA { | |
constructor(state, ea) { | |
state.heading += '[hello from child A]'; | |
this.state = state; | |
this.ea = ea; | |
} | |
attached() { | |
this.subscriber = this.ea.subscribe('testEvent', response => { | |
alert(response.testValue); | |
}); | |
} | |
detached(){ | |
this.subscriber.dispose(); | |
} | |
} |
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 slot="somename" class="child"> | |
Child B | |
</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
import {inject} from 'aurelia-framework'; | |
import {SharedState} from './shared-state'; | |
import {EventAggregator} from 'aurelia-event-aggregator'; | |
@inject(SharedState,EventAggregator) | |
export class ChildB { | |
constructor(state, ea) { | |
alert("childb") | |
state.heading += '[hello from child A]'; | |
this.state = state; | |
this.ea = ea; | |
} | |
attached() { | |
this.subscriber = this.ea.subscribe('testEvent', response => { | |
alert(response.testValue); | |
}); | |
} | |
detached(){ | |
this.subscriber.dispose(); | |
} | |
} |
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"> | |
<style> | |
.shared-parent, | |
.shared-parent > form { | |
border: 5px solid green; | |
padding: 10px; | |
} | |
.shared-parent > form { | |
width: 50%; | |
} | |
.child { | |
border: 5px solid blue; | |
margin-top: 10px; | |
padding: 10px; | |
} | |
</style> | |
</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> | |
<p>viewmodel-with-subrouter.html</p> | |
<router-view layout-view="shared-parent.html" layout-view-model="shared-parent"></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
import {bindable} from 'aurelia-framework'; | |
export class ViewmodelWithSubrouter { | |
@bindable router; | |
heading = 'viewmodel-with-subrouter'; | |
configureRouter(config, router) { | |
config.map([ | |
{ route: ['','shared-parent/child-a'], moduleId: './child-a' , nav: true, title: 'Shared Parent - child-a' }, | |
{ route: 'shared-parent/child-b', moduleId: './child-b', nav: true, title: 'Shared Parent - child-b' }, | |
]); | |
this.router = router; | |
} | |
constructor() {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment