Skip to content
This repository has been archived by the owner on Nov 16, 2021. It is now read-only.

unable to load svg from api #148

Open
snackbearer opened this issue Sep 25, 2020 · 1 comment
Open

unable to load svg from api #148

snackbearer opened this issue Sep 25, 2020 · 1 comment
Labels

Comments

@snackbearer
Copy link

I am unable to load an SVG from api call, I get the error 'Safe Value' must us property binding. I don't have this problem when I use an <img [src]> I assume there is a problem with custom binding? is there an alternate way to load an svg from an api?

I get the following error when I try to bind inlineSVG to an API call:

http://localhost:4200/SafeValue%20must%20use%20[property]=binding:%20blob:http://localhost:4200/f2ab70a1-78ab-433e-b4da-e61e2ab4dd27%20(see%20http://g.co/ng/security

This is my binding: in the template

this is my code for loading from the API

    this.http.get(url, {responseType: 'blob'})
    .pipe(takeUntil(this.onDestroy))
    .subscribe(success => {
      
      let returnUrl = URL.createObjectURL(success);

      console.log('securesvg:' + returnUrl);
      
      observer.next(this.sanitizer.bypassSecurityTrustUrl(returnUrl));
      
    }, error => (this.handleError(error)));
@arkon
Copy link
Owner

arkon commented Sep 27, 2020

You're missing the template info in your issue, but it sounds like you're missing the brackets around the directive attribute?

@arkon arkon added the question label Sep 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants