Last active
February 26, 2016 18:10
-
-
Save JeroenVinke/ee72e9331e645f84c26a 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
import {inject, noView, ViewCompiler, ViewResources, Container, ViewSlot} from 'aurelia-framework'; | |
@noView | |
@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, this.resources); | |
let view = viewFactory.create(this.container); | |
view.bind(viewModel, this); | |
let anchorIsContainer = true, | |
viewSlot = new ViewSlot(containerElement, anchorIsContainer); | |
viewSlot.add(view); | |
viewSlot.attached(); | |
return () => viewSlot.remove(view); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment