angular.js - angularjs ng-bind-html how to insert the entire HTML
世界只因有你
世界只因有你 2017-05-15 16:55:07
0
1
588
$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>

I wrote the already written instructions in Content, and then the output result was that there was only one tag with no content in it

世界只因有你
世界只因有你

reply all(1)
刘奇

Insert the entire HTML使用的是ng-include而不是ng-bind或者ng-bind-template;我这里写的有一个例子,你可以看看,demo。当然你也可以使用$templateCacheservice 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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template