Search code examples
htmlcsscordovangcordovahtml5-filesystem

package image works in style but not in img


I am using ng-cordova, I have stored an image in a subdirectory of cordova.file.dataDirectory, and am unable to load it via img[src] but I can load it via [style], do I have to do anything special to make it work in the img[src]?

$scope

{
"Image":"file:///data/data/{package}/files/{subdir}/{imagename}.png"
}

Works

<div style="background-image:url({{Image}})"></div>

Doesn't work

<img src="{{Image}}" />

Solution

  • This was a silly error, I forgot to check my $compileProvider service. I had it working for filesystem but not file.

    $compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|local|data|filesystem|file):/);