Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on dropping an image #18

Open
miliu99 opened this issue Apr 13, 2017 · 1 comment
Open

Error on dropping an image #18

miliu99 opened this issue Apr 13, 2017 · 1 comment

Comments

@miliu99
Copy link

miliu99 commented Apr 13, 2017

Just got this up and running. However, when I try to drop an image, I got this error in browser console:

WARNING: sanitizing unsafe URL value C:\temp\home.jpg (see http://g.co/ng/security#xss)
browser_adapter.js:122 

WARNING: sanitizing unsafe URL value C:\temp\home.jpg (see http://g.co/ng/security#xss)
unsafe:C:\temp\home.jpg:1 

GET unsafe:C:\temp\home.jpg net::ERR_UNKNOWN_URL_SCHEME

And image doesn't show up. What's the workaround?

@miliu99
Copy link
Author

miliu99 commented Apr 13, 2017

Okay, I figured out myself based on this stackoverflow post by Helzgate (not the accepted answer!).

So, import DomSanitizer first

import { DomSanitizer } from '@angular/platform-browser';

added to contructor

constructor(private sanitizer: DomSanitizer) {}

and change the binding to

<img class="media-object" [src]="sanitizer.bypassSecurityTrustResourceUrl(image.path)" style="max-width:200px">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant