文章詳情頁
angular.js - angularjs動態(tài)增加DOM
瀏覽:137日期:2024-09-28 10:15:46
問題描述
我是用append動態(tài)增加的,但是內(nèi)容不能綁定了
$('#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>')
請問有什么辦法么?
問題解答
回答1:因為你的Html是異步的,需要使用$compile服務來手動編譯記得依賴注入 $compile
var el=$compile('HTML代碼')(scope); $(’#chat’).append(el);回答2:
使用
$compile('<p></p>')($scope)
來綁定~~
上一條:angular.js - 當ui-view放在body元素上,為什么會導致angular重復啟動下一條:angular.js - angular TypeError: Cannot read property ’id’ of undefined?
相關文章:
1. python - 獲取到的數(shù)據(jù)生成新的mysql表2. javascript - js 對中文進行MD5加密和python結果不一樣。3. mysql里的大表用mycat做水平拆分,是不是要先手動分好,再配置mycat4. window下mysql中文亂碼怎么解決??5. sass - gem install compass 使用淘寶 Ruby 安裝失敗,出現(xiàn) 4046. python - (初學者)代碼運行不起來,求指導,謝謝!7. 為啥不用HBuilder?8. python - flask sqlalchemy signals 無法觸發(fā)9. python的文件讀寫問題?10. 為什么python中實例檢查推薦使用isinstance而不是type?
排行榜

熱門標簽