Created
April 26, 2016 20:30
-
-
Save jdanyow/b075366d29f2400d3cc931f6fc26db24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<require from="./thing"></require> | |
<thing name="A"> | |
<thing name="B"> | |
<thing name="C"> | |
<thing name="D"> | |
</thing> | |
</thing> | |
</thing> | |
</thing> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class App { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Aurelia</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<style> | |
thing { | |
display: block; | |
border: 1px solid blue; | |
padding: 5px 5px; | |
} | |
</style> | |
</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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {resolver} from 'aurelia-dependency-injection'; | |
@resolver() | |
export class OptionalParent { | |
constructor(key) { | |
this.key = key; | |
} | |
get(container) { | |
if (container.parent && container.parent.hasResolver(this.key, false)) { | |
return container.parent.get(this.key) | |
} | |
return null; | |
} | |
static of(key) { | |
return new OptionalParent(key); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<h3> | |
My Name is "${name}". | |
<span if.bind="parent">My parent's name is "${parent.name}".</span> | |
<span if.bind="!parent">I don't have a parent.</span> | |
</h3> | |
<content></content> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {bindable, inject} from 'aurelia-framework'; | |
import {OptionalParent} from './optional-parent'; | |
@inject(OptionalParent.of(Thing)) | |
export class Thing { | |
@bindable name; | |
constructor(parent) { | |
this.parent = parent; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment