Skip to content

Instantly share code, notes, and snippets.

@jdanyow
Created March 6, 2016 14:36
Show Gist options
  • Save jdanyow/7cda93aa0a225805ddf6 to your computer and use it in GitHub Desktop.
Save jdanyow/7cda93aa0a225805ddf6 to your computer and use it in GitHub Desktop.
<template>
<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>
${message}
</template>
export class App {
message = 'I am a separate app!';
}
<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