-
-
Save zakjan/5c2d55c58bb270bfab2f41026898cd23 to your computer and use it in GitHub Desktop.
compose with class ref activation
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> | |
<h1>${message}</h1> | |
<div style="display: grid; grid-gap: 20px; grid-template-columns: repeat(2, 1fr)"> | |
<div> | |
<b>String path:</b> | |
<br><br> | |
<template repeat.for="item of items"> | |
<compose view-model="./item" model.bind="{item}"></compose> | |
</template> | |
</div> | |
<div> | |
<b>Class reference:</b> | |
<br><br> | |
<template repeat.for="item of items"> | |
<compose view-model.bind="ItemCustomElement" model.bind="{item}"></compose> | |
</template> | |
</div> | |
<div> | |
<b>String path:</b> | |
<br><br> | |
<template repeat.for="i of items"> | |
<compose view-model="./item" model.bind="{item: i}"></compose> | |
</template> | |
</div> | |
<div> | |
<b>Class reference:</b> | |
<br><br> | |
<template repeat.for="i of items"> | |
<compose view-model.bind="ItemCustomElement" model.bind="{item: i}"></compose> | |
</template> | |
</div> | |
</div> | |
</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 {ItemCustomElement} from './item'; | |
export class App { | |
message = 'Hello World!'; | |
ItemCustomElement = ItemCustomElement; | |
items = new Array(10).fill().map((_, i) => ({text: 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
<!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 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> | |
<span style="margin-right: 5px"> | |
${activated ? '✓' : '×'} | |
</span> | |
${item.text} | |
${text} | |
<br> | |
</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 {computedFrom} from "aurelia-framework"; | |
export class ItemCustomElement { | |
activate(params) { | |
this.item = params.item; | |
this.activated = true; | |
} | |
@computedFrom("item") | |
get text() { | |
return this.item.text * 2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment