arkon / ng-inline-svg

[Inactive] Angular directive for inserting an SVG file inline within an element.
https://echeung.me/ng-inline-svg/
MIT License
210 stars 88 forks source link

unable to load svg from api #148

Open snackbearer opened 3 years ago

snackbearer commented 3 years ago

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 <div [inlineSVG]="processFlow.imageUrl | securesvg | async" >

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 commented 3 years ago

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