angular js ng html in ng repeat won'不起作用

angular js ng-html inside ng-repeat won't work

本文关键字:ng won 不起作用 repeat js html in angular      更新时间:2023-09-26

我将AngularJS与生成html响应的第三方服务一起使用。我想使用ng-repeat将HTML响应呈现为列表,但是Angular没有将其显示为

我创建了这个jsFiddle来演示我的问题。

创建一个用于信任内容的过滤器

<div ng-bind-html="myData | trustAs"></div>

angular.module('app').filter('trustAs', ['$sce', 
    function($sce) {
        return function (input, type) {
            if (typeof input === "string") {
                return $sce.trustAs(type || 'html', input);
            }
            console.log("trustAs filter. Error. input isn't a string");
            return "";
        };
    }
]);

原始答案https://stackoverflow.com/a/34783962/3769965

工作小提琴:https://jsfiddle.net/ebinmanuval/LL5mr7tw/1/