Closed tvsbrent closed 11 months ago
Sorry for the confusion, if you want to use galleryItemDef
you will need to add the item differently. Either use the interface GalleryItem
or galleryRef.add()
function
Here is the docs for galleryItemDef.
Here is a fixed stackblitz https://stackblitz.com/edit/ngx-gallery-5rmee4?file=src%2Fmain.ts
The implementation reserves the main types for the predefined templates.
Ah, thanks so much for that clarification and updates to the documentation! That works well.
One additional point that may be worth mentioning in the documentation is that if you have strict templates on in the project, you may have to work around the compiler complaining about certain variants of GalleryItemData
not having certain properties. That can be seen in the screenshot below. Note that I'm I am not doing any sort of check on the type
field, as I know that I only have images in this list of items:
I found that I had to wrap item
in $any(item)
to get around the compiler check there.
@tvsbrent Thanks for mentioning, will review what can be done to improve it
What is the expected behavior?
The example in the documentation for using the
galleryItemDef
to create a custom item definition template should work.What is the current behavior?
Due to the switch case logic in the
gallery-item.component.ts
file, theconfig.itemTemplate
cannot be called, as it is preceded by the cases for the supported item types. Meaning, if the gallery item is one of the 4 supported types - which the item would have to be - the item template won't be called.What are the steps to reproduce?
Stackblitz Example with Hack
What is the use-case or motivation for changing an existing behavior?
It doesn't seem the behavior described in the documentation works at this time.
Which versions are you using for the following packages?
Is there anything else we should know?
Below is a quick diff showing one possible solution. It involves checking for the presence of the
config.itemTemplate
first and then, if that is not set, falling into the switch case for the items. Also, in the change below, theImage
type becomes the default case, which may not be desired.Possible Solution Patch
```diff import { GalleryItemData, ImageItemData, VideoItemData, YoutubeItemData } from ' selector: 'gallery-item', changeDetection: ChangeDetectionStrategy.OnPush, template: ` -