Skip to content

Instantly share code, notes, and snippets.

@jdanyow
Last active March 6, 2016 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdanyow/5115c4f8900cd186a364 to your computer and use it in GitHub Desktop.
Save jdanyow/5115c4f8900cd186a364 to your computer and use it in GitHub Desktop.
Aurelia - Creating a wrapper around a compose binding and bind to the composed view model
<template>
<require from="./widget-wrapper"></require>
<widget-wrapper module-name="foo"></widget-wrapper>
</template>
export class App {
}
<template>
${message}
</template>
export class Foo {
name = 'my name is foo';
message = 'hello world!';
}
<!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://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>
<h1>${composeViewModel.currentViewModel.name}</h1>
<compose view-model.ref="composeViewModel" view-model.bind="moduleName"></compose>
</template>
import {bindable} from 'aurelia-framework';
export class WidgetWrapper {
@bindable moduleName;
bind() {
console.log(this.composeController);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment