Last active
February 6, 2018 08:08
-
-
Save evenflow58/a52a0c17d0f7bae22b9ea1987ddc5583 to your computer and use it in GitHub Desktop.
DI inheritance
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="./baseGrid"></require> | |
<require from="./grid"></require> | |
<!-- Works as expected --> | |
<base-grid></base-grid> | |
-------------------------------------------- | |
<!-- Works as expected --> | |
<grid></grid> | |
-------------------------------------------- | |
<!-- Does not resolve because the templating engine extracts out the body template --> | |
<grid> | |
<template replace-part="body"> | |
<tr repeat.for="datum of data"> | |
<td> | |
app: ${datum} | |
</td> | |
</tr> | |
</template> | |
</grid> | |
-------------------------------------------- | |
<!-- This resolves the problem but is a bad approach --> | |
<base-grid> | |
<template replace-part="table"> | |
<table> | |
<tbody> | |
<tr repeat.for="datum of data"> | |
<td> | |
bad-app: ${datum} | |
</td> | |
</tr> | |
</tbody> | |
</table> | |
</template> | |
</base-grid> | |
</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'; } |
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> | |
<template replaceable part="table"> | |
<table> | |
<tr repeat.for="datum of data"> | |
<td>${datum}</td> | |
</tr> | |
</table> | |
</template> | |
</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 BaseGrid { | |
data = 'This is the base grid'.split(' '); | |
} |
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 {inject} from 'aurelia-dependency-injection' | |
export class Action1Dependency {} | |
export class Action2Dependency {} | |
export class ActionBase{ | |
} | |
@inject(Action1Dependency) | |
export class Action1 extends ActionBase{ | |
constructor(dep){ | |
super(); | |
this.dep = dep; | |
} | |
} | |
@inject(Action2Dependency) | |
export class Action2 extends ActionBase{ | |
constructor(dep){ | |
super(); | |
this.dep = dep; | |
} | |
} |
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="./baseGrid"></require> | |
<base-grid> | |
<template replace-part="table"> | |
<table> | |
<tbody> | |
<template replaceable part="body"> | |
<tr repeat.for="datum of data"> | |
<td> | |
grid: ${datum} | |
</td> | |
</tr> | |
</template> | |
</tbody> | |
</table> | |
</template> | |
</base-grid> | |
</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 Grid { } |
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