Created
October 4, 2016 16:51
-
-
Save fkleuver/16e2eb80c1ebe8e66bca213574f19a28 to your computer and use it in GitHub Desktop.
Aurelia Gist
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="./parent-element"></require> | |
| <parent-element></parent-element> | |
| </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
| <template> | |
| <p if.bind="isLoaded">I'm loaded!</p> | |
| <p if.bind="!isLoaded">I'm not loaded</p> | |
| </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 { inject } from "aurelia-framework"; | |
| @inject(Element) | |
| export class ChildElement { | |
| constructor (element) { | |
| this.isLoaded = false; | |
| this.element = element; | |
| } | |
| attached () { | |
| setTimeout(() => { | |
| this.isLoaded = true; | |
| this.aPropertyOnlyAvailableAfterLoadingIsComplete = true; | |
| this.element.dispatchEvent(new CustomEvent("loaded", { | |
| bubbles: true | |
| })); | |
| }, 2000); | |
| } | |
| } |
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://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script> | |
| <script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script> | |
| <script> | |
| System.import('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> | |
| <require from="./child-element"></require> | |
| <child-element view-model.ref="child" loaded.delegate="onChildLoaded($event)"></child-element> | |
| </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 ParentElement { | |
| attached () { | |
| } | |
| onChildLoaded($event) { | |
| alert(this.child.aPropertyOnlyAvailableAfterLoadingIsComplete); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment