Last active
January 5, 2018 17:09
-
-
Save djedi/f57a74d904525e243146af6ee46de86b to your computer and use it in GitHub Desktop.
get attribute from parent
This file contains hidden or 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="./my-radio-holder"></require> | |
<require from="./my-radio"></require> | |
<my-radio-holder name="myname" id="force"> <!-- id is optional --> | |
<my-radio>Option 1</my-radio> | |
<my-radio>Option 2</my-radio> | |
</my-radio-holder> | |
</template> |
This file contains hidden or 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 hidden or 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"> | |
</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 hidden or 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> | |
<div><slot></slot></div> | |
</template> |
This file contains hidden or 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'; | |
@inject(Element) | |
export class MyRadioHolder { | |
@bindable name; | |
constructor(element) { | |
this.element = element; | |
} | |
attached() { | |
console.debug('[this.element]', this.element.children[0]); | |
let elem = this.element.children[0]; | |
elem.childNodes.forEach((n) => { | |
if (n.tagName === 'MY-RADIO') { | |
n.children[0].name = this.name; | |
} | |
}) | |
} | |
} |
This file contains hidden or 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> | |
<input type="radio" id.bind="id"><slot></slot></input> | |
</template> |
This file contains hidden or 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 MyRadio { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment