-
-
Save martonsagi/b23bf709d98b3bd3ae427852f104c890 to your computer and use it in GitHub Desktop.
Aurelia Compose view-model.ref
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="./custom-component"></require> | |
<require from="./body-component"></require> | |
<require from="./footer-component"></require> | |
<h1>${message}</h1> | |
<body-component> | |
<compose view-model="./custom-component" view-model.ref="customVM"></compose> | |
</body-component> | |
<footer-component> | |
<button if.bind="customVM.currentViewModel.canSave">So you think you can save now?</button> | |
</footer-component> | |
</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 { | |
message = 'Hello World!'; | |
attached() { | |
console.log("This should be a 'Compose' instance", this.customVM); | |
} | |
} |
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> | |
<div><strong>Body Component</strong></div> | |
<hr> | |
<div> | |
<slot></slot> | |
</div> | |
<hr> | |
</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 BodyComponent { | |
} |
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> | |
<div> | |
My Custom Component | |
<br> | |
<label><input type="checkbox" checked.bind="controlFlag"> Check to set 'canSave=true'</label> | |
</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 { observable, computedFrom } from 'aurelia-framework'; | |
export class CustomComponent { | |
@observable | |
controlFlag = false; | |
get canSave() { | |
return this.controlFlag; | |
} | |
controlFlagChanged() { | |
console.log(this.canSave); | |
} | |
} |
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