首页 > angularjs动态增加DOM

angularjs动态增加DOM

我是用append动态增加的,但是内容不能绑定了

$("#chat").append("<div class='eve_chat clearfloat'><div style='width:calc(98% - 50px);' class='clearfloat mb10'><img src='../../img/goods/3.jpg' class='chat_face left'><div class='chat_pop_left'><div class='chat_content left'><p>{{messages.messagetxt}}</p></div></div></div></div>")

请问有什么办法么?


因为你的Html是异步的,需要使用$compile服务来手动编译
记得依赖注入 $compile

var el=$compile("HTML代码")(scope); $('#chat').append(el);

使用

 $compile("<div></div>")($scope)
 

来绑定~~

【热门文章】
【热门文章】