您的位置:首頁技術文章
文章詳情頁

angular.js - angularjs動態增加DOM

瀏覽:163日期:2024-09-28 10:15:46

問題描述

我是用append動態增加的,但是內容不能綁定了

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

angular.js - angularjs動態增加DOM

請問有什么辦法么?

問題解答

回答1:

因為你的Html是異步的,需要使用$compile服務來手動編譯記得依賴注入 $compile

var el=$compile('HTML代碼')(scope); $(’#chat’).append(el);回答2:

使用

$compile('<p></p>')($scope)

來綁定~~

相關文章:
国产综合久久一区二区三区