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. javascript - ueditor引入报错问题2. html5 - 响应式WEB,媒体查询的问题。3. 关docker hub上有些镜像的tag被标记““This image has vulnerabilities””4. boot2docker无法启动5. dockerfile - [docker build image失败- npm install]6. nignx - docker内nginx 80端口被占用7. docker start -a dockername 老是卡住,什么情况?8. docker容器呢SSH为什么连不通呢?9. angular.js - angular内容过长展开收起效果10. dockerfile - 为什么docker容器启动不了?

网公网安备