Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/477.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 当html由js呈现时,Angular ng模型不起作用_Javascript_Jquery_Angularjs_Dom - Fatal编程技术网

Javascript 当html由js呈现时,Angular ng模型不起作用

Javascript 当html由js呈现时,Angular ng模型不起作用,javascript,jquery,angularjs,dom,Javascript,Jquery,Angularjs,Dom,我有一个jquery插件,它在DOM中呈现一些html。我将ng model属性设置为jquery插件中的注入html 页面加载完成后,ng model不会绑定到angular 从jquery添加属性: attributes: { dir : "ltr", spellcheck : false, "ng-model" : "userContent", id : "myID" }

我有一个
jquery
插件,它在
DOM
中呈现一些html。我将
ng model
属性设置为jquery插件中的注入html

页面加载完成后,
ng model
不会绑定到angular

从jquery添加属性:

attributes: {
    dir               : "ltr",
    spellcheck        : false,
    "ng-model"        : "userContent",
    id                : "myID"
}
页面加载后,这将添加到html中:

<div dir="ltr" spellcheck="false" ng-model="userContent2" id="myID" contenteditable="true">Test</div>
测试

注意:我使用html进行了测试,html已经存在于
DOM
中。(它与contenteditable无关)

看起来很奇怪,你不会使用angular来呈现所需的html,而只是将JavaScript连接到它。这不会发生,因为angular需要了解指令属性并编译它们。插件需要使用
$compile
来实现这一点。您是否尝试过将userContent2模型绑定到一个类似这样的东西中:插件是什么,它做了什么,您如何初始化它?看见