Last active
March 17, 2017 05:14
-
-
Save plwalters/9c0053625209e0ff7fe87e5fa2574862 to your computer and use it in GitHub Desktop.
DI inheritance
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> | |
<require from="./child-element-two"></require> | |
<h2>Parent Errors below</h2> | |
<ul> | |
<li repeat.for="error of errors"> | |
${error.name} | |
</li> | |
</ul> | |
<child-element></child-element> | |
<child-element-two></child-element-two> | |
</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 { | |
errors = []; | |
} |
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> | |
<h2>Child Two Errors below</h2> | |
<ul> | |
<li repeat.for="error of errors"> | |
${error.name} | |
</li> | |
</ul> | |
<button click.delegate="addError()">Add Error From Child</button> | |
</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} from 'aurelia-framework'; | |
import {App} from './app'; | |
export class ChildElementTwo { | |
@bindable errors = []; | |
static inject = [App]; | |
constructor(app) { | |
this.app = app; | |
} | |
addError() { | |
let newError = new ErrorItem(); | |
this.errors.push(newError); | |
this.app.errors.push(newError); | |
} | |
} | |
class ErrorItem { | |
name = ''; | |
constructor() { | |
this.name = 'Error two'; | |
} | |
} |
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> | |
<h2>Child One Errors below</h2> | |
<ul> | |
<li repeat.for="error of errors"> | |
${error.name} | |
</li> | |
</ul> | |
<button click.delegate="addError()">Add Error From Child</button> | |
</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} from 'aurelia-framework'; | |
import {App} from './app'; | |
export class ChildElement { | |
@bindable errors = []; | |
static inject = [App]; | |
constructor(app) { | |
this.app = app; | |
} | |
addError() { | |
let newError = new ErrorItem(); | |
this.errors.push(newError); | |
this.app.errors.push(newError); | |
} | |
} | |
class ErrorItem { | |
name = ''; | |
constructor() { | |
this.name = 'Error one'; | |
} | |
} |
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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment