Closed nishant closed 3 years ago
You can use href
<a href="{{item.image}}"></a>
or
<a [attr.href]="item.image"></a>
<lightgallery [settings]="settings" [onBeforeSlide]="onBeforeSlide">
<a *ngFor="let item of items" [attr.href]="item.image">
<img className="img-responsive" src="{{ item. thumbnail }}" />
</a>
</lightgallery>
Demo - https://stackblitz.com/edit/lightgallery-angular-update-slides?file=src%2Fapp%2Fapp.component.html
let me know if you have any questions
resolved with prefixing the existing attributes with attr.
(no square brackets)
working with the following block:
<a *ngFor="let item of items"
class="gallery-item"
attr.data-src="{{ item.image }}"
attr.data-sub-html="{{ replacePlaceholderText(item.title, item.location) }}">
<img class="img-responsive" src="{{ item.thumbnail }}" alt="Image Thumbnail">
</a>
marking this issue as closed. tysm for the quick response! really appreciate it👍
edit - went with this approach in the end:
<lightgallery [settings]="settings" [onBeforeSlide]="onBeforeSlide">
<a *ngFor="let item of items" class="gallery-item"
[attr.href]="item.image"
[attr.data-sub-html]="replacePlaceholderText(item.title, item.location)">
<img class="img-responsive" src="{{ item.thumbnail }}" alt="Image Thumbnail"/>
</a>
</lightgallery>
Description
*ngFor
is not working ona
tags inside thelightgallery
component. Error is as follows:NG8002: Can't bind to 'src' since it isn't a known property of 'a'.
Steps to reproduce
I have created a static object containing all data needed for the
<a>
tags:Usage in app component html:
This results in a failed build with the following error message:
Expected result
Under normal usage without the *ngFor, everything loads and renders fine:
Any help resolving this issue would be appreciated as I have a large number of images to display and static html is much too lengthy.