$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 class="u-formatedText" ng-bind-html="page.content"></p>
我在Content里面写已经写好的指令,然后输出结果是只有一个标签,里面没有内容
怪我咯2017-05-15 16:57:07
Insert the entire HTML
使用的是ng-include
而不是ng-bind
或者ng-bind-template
;我这里写的有一个例子,你可以看看,demo。当然你也可以使用$templateCache
service to achieve your desired results.
It was wrong at first glance. It turned out to be the ng-bind-html
,我还以为是ng-bind-template
,使用ng-bind-html
之前,要引入ngSanitize
module, otherwise an error would have been reported. The official example is here ngBindHtml, you can take a look.