A minimal Angular application showing how to integrate the Cloudinary Product Gallery Widget into an Angular project. The demo renders images, video, and 360° spin assets sourced from Cloudinary tags.
- Loading the Cloudinary Product Gallery Widget script via
index.html - Wrapping the widget in a reusable, standalone Angular component (
ProductGalleryComponent) - Initialising the widget with
ngAfterViewInitand targeting a native DOM element viaViewChild - Cleaning up the widget with
ngOnDestroyto avoid memory leaks - Passing
cloudNameandmediaAssetsinto the component as@Input()properties
- Node.js 18 or later
- A Cloudinary account — sign up free
No additional npm packages are required. The gallery widget is loaded directly from Cloudinary's CDN.
git clone https://github.com/cloudinary-devs/cld-angular-product-gallery.git
cd cld-angular-product-gallerynpm installOpen src/app/app.ts and replace 'demo' with your own Cloudinary cloud name:
readonly cloudName = 'your-cloud-name';Update mediaAssets to reference your own tags, or keep the demo tags to see the electric car example straight away.
npm startNavigate to http://localhost:4200/ — the gallery will render automatically.
src/
├── index.html # Loads the Cloudinary gallery widget script
└── app/
├── app.ts # Root component — sets cloudName & mediaAssets
├── app.html # Page layout
├── app.scss # App-level styles
└── product-gallery/
└── product-gallery.component.ts # Standalone gallery component
The widget script exposes a global cloudinary object. ProductGalleryComponent calls cloudinary.galleryWidget() after the view is ready and destroys it when the component is torn down:
ngAfterViewInit(): void {
this.widget = cloudinary.galleryWidget({
container: this.galleryContainer.nativeElement,
cloudName: this.cloudName,
mediaAssets: this.mediaAssets,
});
this.widget.render();
}
ngOnDestroy(): void {
this.widget?.destroy();
}The component accepts two inputs so it can be reused anywhere in your app:
| Input | Type | Description |
|---|---|---|
cloudName |
string |
Your Cloudinary cloud name |
mediaAssets |
CloudinaryMediaAsset[] |
Array of tag-based asset definitions |
Each asset entry supports tag (required) and an optional mediaType of 'image' (default), 'video', or 'spin'.
- Product Gallery Widget documentation
- Product Gallery Widget demo
- Cloudinary Angular SDK
- Cloudinary sign-up
npm run buildOutput is written to the dist/ directory, optimized for production.