Skip to content

Instantly share code, notes, and snippets.

@Vheissu
Last active December 14, 2016 01:53
Show Gist options
  • Save Vheissu/9127f7ebf5c4a21c8d030e2f381591a8 to your computer and use it in GitHub Desktop.
Save Vheissu/9127f7ebf5c4a21c8d030e2f381591a8 to your computer and use it in GitHub Desktop.
Dynamic view creation in Aurelia
<template>
<compose view.bind="viewStrategy"></compose>
</template>
import {InlineViewStrategy} from 'aurelia-framework';
export class App {
constructor() {
this.viewStrategy = null;
this.myValue = 'a value from the view-model';
}
bind(bindingContext: any, overrideContext: any) {
this.viewStrategy = new InlineViewStrategy('<template>This is my string with ${myValue}</template>');
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment