Aurelia not binding innerHTML bind statements

痞子三分冷 提交于 2020-06-28 05:48:08

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!