Last active
July 13, 2017 18:04
-
-
Save AStoker/39b571d960bc9d8a0e38bd4688a3a0d4 to your computer and use it in GitHub Desktop.
Replaceable list repeaters
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="CustomElement1"></require> | |
Hello world | |
<br /> | |
<custom-element1 items.bind="items"></custom-element1> | |
</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 { | |
items = []; | |
constructor () { | |
for (let i = 0; i < 5; i++) { | |
this.items.push({ | |
id: i, | |
text: `Item: ${i}` | |
}); | |
} | |
} | |
} |
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="CustomElement2"></require> | |
<label>Custom Element 1</label> | |
<br /> | |
<custom-element2 items.bind="items2"> | |
<template replace-part="item"> | |
<li repeat.for="item of items"> | |
<label>${item.text}</label> | |
</li> | |
</template> | |
</custom-element2> | |
</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 {inject, bindable, BindingEngine} from 'aurelia-framework'; | |
@inject(BindingEngine) | |
export class CustomElement1 { | |
@bindable items; | |
constructor(bindingEngine) { | |
this.items2 = []; | |
} | |
bind() { | |
this.items2 = this.items; | |
} | |
} |
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> | |
<label>Custom Element 2</label> | |
<ul> | |
<li replaceable part="item" repeat.for="item of items"> | |
<label>${item.text}</label> | |
</li> | |
</ul> | |
</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} from 'aurelia-framework'; | |
export class CustomElement2 { | |
@bindable items; | |
} |
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"> | |
</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