angular.js - angularjs ng-bind-html如何插入整段HTML
問題描述
$scope.pages = [{ title: ’信息’, content: ’detailMessage’}, { title: ’集裝箱/車’, content: ’dddd’}, { title: ’貨物’, content: ’eee’}, { title: ’記錄’, content: ’fff’}];
.directive(’detailMessage’, function() {return { restrict: ’EC’, templateUrl: ’views/partials/message.html’, transclude: true, replace: true}; })
<p ng-bind-html='page.content'></p>
我在Content里面寫已經寫好的指令,然后輸出結果是只有一個標簽,里面沒有內容
問題解答
回答1:插入整段HTML使用的是ng-include而不是ng-bind或者ng-bind-template;我這里寫的有一個例子,你可以看看,demo。當然你也可以使用$templateCache服務來實現你想要的結果。
第一眼看錯了,原來是ng-bind-html,我還以為是ng-bind-template,使用ng-bind-html之前,要引入ngSanitize模塊,不然會報錯的,官方示例在這里ngBindHtml,你可以看看。
相關文章:
1. IOS app應用軟件的id號怎么查詢?比如百度貼吧的app-id=4779278132. 運行python程序時出現“應用程序發生異常”的內存錯誤?3. spring-mvc - spring-session-redis HttpSessionListener失效4. 利用IPMI遠程安裝centos報錯!5. javascript - node得到req不能得到boolean6. mysql - 查詢 修改數據庫優化問題吧7. javascript - input 是不是不能同時用:value和v-model8. javascript - 最近用echarts做統計圖時遇到兩個問題!!9. javascript - 引入 simditor,但是顯示標簽,這個怎么解決。10. 淺談Vue使用Cascader級聯選擇器數據回顯中的坑

網公網安備