Angularjs在节点webkit应用程序中将image src更改为“unsafe:”

时间:2015-02-19 12:01:08

标签: javascript angularjs node-webkit

我正在开发AngularJS NodeWebkit应用程序并添加图像src,如下所示



<div ng-repeat="product in product.productList" >
<img class="product-image" ng-src="images/product-{{product.id}}.png" alt="image" with='50' height='50'  />
</div>
&#13;
&#13;
&#13;

它在网络浏览器中表现不错,但是当它进入节点webkit应用程序时,src会附加“不安全”。例如: -

&#13;
&#13;
<img class="product-image" ng-src="/images/product-24586.png" src="unsafe:app//myapp/images/product-24586.png" alt="image" with='50' height='50'  />
&#13;
&#13;
&#13;

我尝试了波纹管修复,但没有运气

&#13;
&#13;
var myModule = angular.module('myApp', [...], function($compileProvider) {
    ...
    $compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|file|chrome-extension):|data:image\//);
    $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|chrome-extension):/);
});
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

Node-webkit提供app协议。根据{{​​3}}将其视为本地文件协议。 因此,您必须将应用协议列入白名单。

var myModule = angular.module('myApp', [...], function($compileProvider) { $compileProvider.imgSrcSanitizationWhitelist('app://'); });