Skip to content

Instantly share code, notes, and snippets.

@plwalters
Created April 12, 2016 16:00
Show Gist options
  • Save plwalters/0ec3632bfd6a2ecb79ed4b155eb98e02 to your computer and use it in GitHub Desktop.
Save plwalters/0ec3632bfd6a2ecb79ed4b155eb98e02 to your computer and use it in GitHub Desktop.
Aurelia If Bind test on <content>
<template>
<require from="./parent"></require>
<parent></parent>
</template>
export class App {
}
<template>
<button click.trigger="logParentId()">button from child</button>
</template>
import {Parent} from './parent'
export class Child {
static inject = [Parent];
constructor(parent) {
this.parent = parent;
console.log(parent);
}
logParentId() {
console.log(this.parent.id);
}
}
<!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>
<require from="./child"></require>
<div>Hello</div>
<span>Unique id - ${id}</span>
<br />
<child></child>
</template>
export class Parent {
constructor() {
this.id = Math.random();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment