1

I am working on a AngularJS NodeWebkit application and adding image src as following

<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>

It is coming good in web browser but when it is coming in node webkit application the src is appending with 'unsafe'. eg:-

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

I have tried the bellow fix, but no luck

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):/);
});

1
  • you are using relative url. you expression in config contains and all while..try $compileProvider.imgSrcSanitizationWhitelist('/^\s/img\//'); Commented Feb 19, 2015 at 12:09

1 Answer 1

2

Node-webkit provides app protocol. which according to documentation is treated as local file protocol. So you have to whitelist your app protocol.

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.