问题
Given I have used innerhtml.bind to insert some html but that html includes within it it's own aurelia '.bind' statements how do you get those inner bindings to be recognized by aurelia?
example
<div innerhtml.bind="myhtml"></div>
where
var myhtml = "<div click.trigger='console.log(123)'>some text</div>";
回答1:
The docs say:
Binding using the innerhtml attribute simply sets the element's innerHTML property. The markup does not pass through Aurelia's templating system. Binding expressions and require elements will not be evaluated.
How about creating a component and use a slot?
my-component.html
<template>
<div><slot></slot></div>
</template>
consumer.html
<require from="./my-component.html"></require>
<my-component><div click.trigger='console.log(123)'>some text</div></my-component>
来源:https://stackoverflow.com/questions/41399496/aurelia-not-binding-innerhtml-bind-statements