-
-
Save Vheissu/6b9605f5f86e6212ec81da7393c1b485 to your computer and use it in GitHub Desktop.
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> | |
<compose view.bind="viewStrategy" view-model.bind="viewModel" containerless></compose> | |
</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 {InlineViewStrategy} from 'aurelia-framework'; | |
export class App { | |
viewHtml = '<template><my-element></my-element><h1>${message}</h1></template>'; | |
viewModel = { message: 'hello world' }; | |
viewStrategy; | |
bind() { | |
this.viewStrategy = new InlineViewStrategy(this.viewHtml); | |
} | |
} |
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="main"> | |
<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 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 function configure(aurelia) { | |
aurelia.use | |
.standardConfiguration() | |
.developmentLogging() | |
.globalResources('./my-element'); | |
aurelia.start().then(a => a.setRoot()); | |
} |
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> | |
My Element | |
</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 MyElement { | |
} |
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
textarea { | |
display: block; | |
} | |
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, | |
ViewCompiler, | |
ViewResources, | |
Container, | |
ViewSlot, | |
createOverrideContext | |
} from 'aurelia-framework'; | |
@inject(ViewCompiler, ViewResources, Container) | |
export class ViewFactory { | |
constructor(viewCompiler, resources, container) { | |
this.viewCompiler = viewCompiler; | |
this.resources = resources; | |
this.container = container; | |
} | |
insert(containerElement, html, viewModel) { | |
let viewFactory = this.viewCompiler.compile(html); | |
let view = viewFactory.create(this.container); | |
let anchorIsContainer = true; | |
let viewSlot = new ViewSlot(containerElement, anchorIsContainer); | |
viewSlot.add(view); | |
view.bind(viewModel, createOverrideContext(viewModel)); | |
return () => { | |
viewSlot.remove(view); | |
view.unbind(); | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment