Angularjs 在节点 webkit 应用程序中将图像 src 更改为“不安全:”
Angularjs changes image src to “unsafe:” in node webkit application
我正在开发 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>
它在网络浏览器中表现良好,但在节点 webkit 应用程序中出现时,src 会附加 'unsafe'。例如:-
<img class="product-image" ng-src="/images/product-24586.png" src="unsafe:app//myapp/images/product-24586.png" alt="image" with='50' height='50' />
我试过下面的修复方法,但没有成功
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):/);
});
Node-webkit 提供应用程序协议。根据 documentation,它被视为本地文件协议。
所以你必须将你的应用程序协议列入白名单。
var myModule = angular.module('myApp', [...], function($compileProvider) {
$compileProvider.imgSrcSanitizationWhitelist('app://');
});
我正在开发 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>
它在网络浏览器中表现良好,但在节点 webkit 应用程序中出现时,src 会附加 'unsafe'。例如:-
<img class="product-image" ng-src="/images/product-24586.png" src="unsafe:app//myapp/images/product-24586.png" alt="image" with='50' height='50' />
我试过下面的修复方法,但没有成功
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):/);
});
Node-webkit 提供应用程序协议。根据 documentation,它被视为本地文件协议。 所以你必须将你的应用程序协议列入白名单。
var myModule = angular.module('myApp', [...], function($compileProvider) {
$compileProvider.imgSrcSanitizationWhitelist('app://');
});