ngx-gallery
ngx-gallery copied to clipboard
cannot provide images input as Observable via async pipe
In my use of ngx-gallery I need to provide the images
input in the form of an Observable<NgxGalleryImage[]>
(via the async
pipe). But because the resolution of the observable is asynchronous WRT the initialization of the component I get the following error:
ERROR TypeError: Cannot read property 'length' of null
at NgxGalleryComponent.push../node_modules/ngx-gallery/bundles/ngx-gallery.umd.js.NgxGalleryComponent.ngDoCheck (ngx-gallery.umd.js:1510)
at checkAndUpdateDirectiveInline (core.js:22101)
at checkAndUpdateNodeInline (core.js:23362)
at checkAndUpdateNode (core.js:23324)
at prodCheckAndUpdateNode (core.js:23865)
When the ngx-gallery component is initialized, the images
input is null
, but the error indicates that the the middle condition (the length check) on that line of code is being evaluated anyway (even though images
is null). Perhaps images !== undefined
is too strict a check or not sufficient on its own? It seems like it would be safer to check independently for a null or undefined input, then evaluate the other conditions. Is there an example of how to get the component to consume an Observable via the async pipe? I'm pretty confident that my code generates a valid images collection, just not at the point that the ngx-gallery is first initialized.
Thanks in advance.