Skip to content

Instantly share code, notes, and snippets.

@BruceL33t
Forked from jdanyow/app.html
Created November 24, 2016 21:21
Show Gist options
  • Save BruceL33t/61b46106bc72ff29c96fa89dfc726887 to your computer and use it in GitHub Desktop.
Save BruceL33t/61b46106bc72ff29c96fa89dfc726887 to your computer and use it in GitHub Desktop.
<template>
<p>Parent App</p>
<require from="./child-app"></require>
<child-app main.bind="main1"></child-app>
<child-app main.bind="main2"></child-app>
</template>
export class App {
main1 = './one/app';
main2 = './two/app';
}
import {
Aurelia,
noView,
bindable,
inject,
Container
} from 'aurelia-framework';
import {Loader} from 'aurelia-loader';
@noView()
@inject(Loader, Element)
export class ChildApp {
@bindable main;
constructor(loader, element) {
this.host = element;
this.app = new Aurelia(this.loader, new Container());
this.app.use.standardConfiguration();
}
mainChanged() {
this.app.start().then(a => a.setRoot(this.main, this.host));
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
child-app {
display: block;
border: 1px solid green;
}
</style>
</head>
<body aurelia-app>
<h1>Loading...</h1>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
<template>
<ul>
<li repeat.for = "row of router.navigation">
<a href.bind = "row.href">${row.title}</a>
</li>
</ul>
<router-view></router-view>
</template>
export class App {
message = 'I am a separate app!';
configureRouter(config, router){
config.title = 'Aurelia';
config.map([
{ route: ['','test'], name: 'test',
moduleId: '../test', nav: true, title:'Test' },
{ route: ['test2'], name: 'home2',
moduleId: '../test2', nav: true, title:'Test2' }
]);
this.router = router;
}
}
<template>
${message}
</template>
export class Test {
message = 'test';
}
<template>
${message}
</template>
export class Test2 {
message = 'test2';
}
<template>
${message}
</template>
export class App {
message = 'I am another separate app!';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment