Last active
October 11, 2017 01:17
-
-
Save oneillci/7e86f9e8f98626c8e44dc22a22d99c33 to your computer and use it in GitHub Desktop.
Inheritance problem
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="./my-control"></require> | |
<require from="./my-other"></require> | |
<h1>${message}</h1> | |
<my-control></my-control> | |
<br/> | |
<my-other></my-other> | |
</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 { message = 'Hello World'; } |
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"; | |
import {Service} from "./service"; | |
@inject(Service) | |
export class Base { | |
selectedItem: any; | |
service; | |
constructor(service) { | |
console.log("base constructor", this); | |
this.service = service; | |
} | |
created() { | |
console.log("Created in base") | |
console.log(this.service.getStuff()); | |
} | |
} |
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
import {Base} from "./base"; | |
import {bindable, inlineView, inject} from "aurelia-framework"; | |
import {Service} from "./service"; | |
@inject(Service) | |
@inlineView(` | |
<template> | |
my-control: <input type="text" value.bind="name" /> | |
<div repeat.for="i of items" click.trigger="clicked(i)">\${i}</div> | |
</template> | |
`) | |
export class MyControl extends Base { | |
@bindable items = [1, 2, 3]; | |
@bindable selectedItem; | |
name = "ciaran"; | |
service; | |
constructor(service) { | |
super(service); | |
this.service = service; | |
} | |
created() { | |
super.created(); | |
console.log("created in my control", this.items, this.name) | |
} | |
selectedItemChanged() { | |
console.log("mycontrol selected item is", this.selectedItem); | |
} | |
clicked(i){ | |
console.log(i); | |
this.selectedItem = i; | |
console.log(this.service.getStuff()); | |
} | |
} |
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 {Base} from "./base"; | |
import {bindable, inlineView, inject} from "aurelia-framework"; | |
import {Service} from "./service"; | |
@inject(Service) | |
@inlineView(` | |
<template> | |
my-other: <input type="text" value.bind="name" /> | |
<div repeat.for="i of items" click.trigger="clicked(i)">\${i}</div> | |
</template> | |
`) | |
export class MyOther extends Base { | |
@bindable items = [6,7,8]; | |
@bindable selectedItem; | |
name = "poppy"; | |
service; | |
constructor(service) { | |
super(service); | |
this.service = service; | |
} | |
created() { | |
super.created(); | |
console.log("created in my other", this.items, this.name) | |
} | |
selectedItemChanged() { | |
console.log("myother selected item is", this.selectedItem); | |
} | |
clicked(i){ | |
console.log(i); | |
this.selectedItem = i; | |
console.log(this.service.getStuff()); | |
} | |
} |
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 Service { | |
getStuff() { | |
return [9,0,8]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment