ng-src没有被imgSrcSanitizationWhitelist修复

时间:2015-09-15 10:38:05

标签: angularjs

我正在写一个Firefox插件。我有一个非常简单的代码:

var ANG_APP = angular.module('zooniversexpert', [])
    .config(['$compileProvider', function( $compileProvider ) {
            $compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|http?):/);
        }
    ])
    .controller('BodyController', ['$scope', function($scope) {
        this.gallery = [{url:'http://zooniverse-export.s3-website-us-east-1.amazonaws.com/21484_1000_D35_Season%202_Set%201_EK006076.JPG'}];
    }]);

gallery数组包含url个键http://zooniverse-export.s3-website-us-east-1.amazonaws.com/21484_1000_D35_Season%202_Set%201_EK006076.JPG的单个元素。

我的HTML在这里:

<body ng-controller="BodyController as BC">
    <img ng-src="aEntry.url" ng-repeat="aEntry in BC.gallery"/>
</body>

但是图像无法加载,它不断发出此错误:

Screenshot

对文档的检查表明这是Angular试图加载的内容:

<img xmlns="http://www.w3.org/1999/xhtml" ng-src="aEntry.url" ng-repeat="aEntry in BC.gallery" class="ng-scope" src="unsafe:aEntry.url" />

请注意unsafe:aEntry.url

0 个答案:

没有答案