I want to get background image URL from Event object, Trying following:

.ts file:

  openZoomer(event) {
    if (event.target.className === 'ngx-gallery-image ngx-gallery-active') {
      this.current_image = event.target.style.background.url;
      this.isZooming = true;
    }
  }

.html file:

(click)="openZoomer($event)"

Thanks in advance for any help.

1 Answers

3
ArunKumar M N On

Use,

target.style.backgroundImage

instead of

event.target.style.background.url

it will give something like this

"url("someurl")"

then use replace function to extract the urlpart

event.target.style.backgroundImage.replace("url\(","").replace("\)","").replace("\"","").replace("\"","");

then you will get someurl