Angular PrimeNG Image Events Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will know how to use Angular PrimeNG Image Events. The Image Component is used to display a single image with preview and transform options. The image component has 3 events named onShow, onHide, and onImageError which are listed below. Angular PrimeNG Image Events: onShow: This event is fired when the image preview overlay is shown.onHide: This event is fired when the image preview overlay is hidden.onImageError: This event is fired if the browser fails to load the image file. This event was added in PrimeNg v14.1.2. Syntax: <p-image src="..." [preview]="true" (image-event)="callbackFunction()" width="..."> </p-image>Creating Angular application & module installation: Step 1: Create an Angular application using the below command. ng new newappStep 2: After creating your project folder i.e. newapp, move to it using the below command. cd newappStep 3: Install PrimeNG and PrimeIcons in your project directory. npm install primeng --save npm install primeicons --saveProject Structure: After complete installation, the project structure will look like the following: Example 1: This example illustrates the use of the onImageError event of the PrimeNG Image component that is triggered when the image fails to load. Here we pass the link to an image file that does not exist so the image will not be loaded triggering the onImageError event. app.component.html HTML <h2 style="color: green">GeeksforGeeks</h2> <h3>Angular PrimeNG Image Events Component</h3> <!-- Image does not exist at the given source --> <p-image src="./fakeImage.jpg" (onImageError)="imageErr()" width="200"> </p-image> <p-toast></p-toast> app.component.ts JavaScript import { Component } from '@angular/core'; import { MessageService } from 'primeng/api'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'], providers: [MessageService] }) export class AppComponent { constructor(private msgs: MessageService) { } imageErr() { setTimeout(() => { this.msgs.add({ severity: 'success', summary: 'Failed to load Image', detail: 'onImageError Event Fired' }); }, 1000); } } app.module.ts JavaScript import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { AppComponent } from './app.component'; import { FormsModule } from '@angular/forms'; import { ImageModule } from 'primeng/image'; import { ToastModule } from 'primeng/toast'; @NgModule({ imports: [ BrowserModule, BrowserAnimationsModule, FormsModule, ImageModule, ToastModule ], declarations: [AppComponent], bootstrap: [AppComponent], }) export class AppModule { } Output: Example 2: In this example, we used the onShow and onHide events of the Image to show a toast message using the message service. app.component.html HTML <h2 style="color: green">GeeksforGeeks</h2> <h3>Angular PrimeNG Image Events Component</h3> <p-image src= "https://media.geeksforgeeks.org/wp-content/uploads/20221023092911/gfglogo-200x200.png" [preview]="true" (onShow)="imageShow()" (onHide)="imageHide()" width="200"> </p-image> <p-toast></p-toast> app.component.ts JavaScript import { Component } from '@angular/core'; import { MessageService } from 'primeng/api'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'], providers: [MessageService] }) export class AppComponent { constructor(private msgs: MessageService) { } imageShow() { this.msgs.add({ severity: 'success', summary: 'Preview Shown', detail: 'onShow Event Fired' }); } imageHide() { this.msgs.add({ severity: 'error', summary: 'Preview Hidden', detail: 'onHide Event Fired' }); } } app.module.ts: JavaScript import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { AppComponent } from './app.component'; import { FormsModule } from '@angular/forms'; import { ImageModule } from 'primeng/image'; import { ToastModule } from 'primeng/toast'; @NgModule({ imports: [ BrowserModule, BrowserAnimationsModule, FormsModule, ImageModule, ToastModule ], declarations: [AppComponent], bootstrap: [AppComponent], }) export class AppModule { } Output: Comment More infoAdvertise with us Next Article Angular PrimeNG Image Templates P prashantrathore1159 Follow Improve Article Tags : Technical Scripter Web Technologies AngularJS Technical Scripter 2022 Angular-PrimeNG +1 More Similar Reads Carousel ComponentAngular PrimeNG Carousel ComponentAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. It provides a lot of templates, components, theme design, an extensive icon library, and much more. 5 min read Angular PrimeNG Carousel BasicAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. This article will show us how to use Basic Carousel in Angular PrimeNG. Angular PrimeNG Basic Carous 4 min read Angular PrimeNG Carousel VerticalAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. This article will show us how to use Basic Carousel in Angular PrimeNG. Angular PrimeNG Basic Carous 4 min read Angular PrimeNG Carousel Items Per Page and Scroll ItemsAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. This article will show us how to use Carousel in Angular PrimeNG. Angular PrimeNG Basic Carousel is 4 min read Angular PrimeNG Carousel ResponsiveAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. This article will show us how to use Basic Carousel in Angular PrimeNG. Angular PrimeNG Basic Carous 4 min read Angular PrimeNG Carousel Header and FooterAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. This article will show us how to use Basic Carousel in Angular PrimeNG. Angular PrimeNG Basic Carous 4 min read Angular PrimeNG Carousel OrientationAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. This article will show us how to use Carousel in Angular PrimeNG. Angular PrimeNG Basic Carousel is 4 min read Angular PrimeNG Carousel AutoPlay and CircularAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. This article will show us how to use Basic Carousel in Angular PrimeNG. Angular PrimeNG Basic Carous 4 min read Angular PrimeNG Carousel PropertiesAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. It provides a lot of templates, components, theme design, an extensive icon library, and much more. 4 min read Angular PrimeNG Carousel EventsAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. It provides a lot of templates, components, theme design, an extensive icon library, and much more. 4 min read Angular PrimeNG Carousel TemplatesAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. It provides a lot of templates, components, theme design, an extensive icon library, and much more. 4 min read Angular PrimeNG Carousel StylingAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. It provides a lot of templates, components, theme design, an extensive icon library, and much more. 4 min read Galleria ComponentAngular PrimeNG Galleria ComponentAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will be seeing Angular PrimeNG Galleria Component. Angular PrimeNG Galleria is a 6 min read Angular PrimeNG Galleria DocumentaionAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will see Angular PrimeNG Galleria Component. The Galleria in Angular PrimeNG is 4 min read Angular PrimeNG Galleria ProgrammaticAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will see the Angular PrimeNG Galleria Programmatic. The Galleria is an advanced 4 min read Angular PrimeNG Galleria IndicatorAngular PrimeNG is an open-source UI component library for Angular Applications. Using the components provided by Angular PrimeNG, one can create stunning and responsive angular applications. In this article, we will see the Angular PrimeNG Galleria Indicator. Galleria is an advanced component to di 5 min read Angular PrimeNG Galleria ThumbnailAngular PrimeNG is an open-source UI component library for Angular Applications. Using the components provided by Angular PrimeNG, one can create stunning and responsive angular applications. In this post, we will see Angular PrimeNG Galleria Thumbnail. Galleria is an advanced component to display i 5 min read Angular PrimeNG Galleria NavigatorAngular PrimeNG is an open-source UI component library for Angular Applications. Using the components provided by Angular PrimeNG, one can create stunning and responsive angular applications. In this article, we will see Angular PrimeNG Galleria Navigator. Galleria is an advanced component to displa 4 min read Angular PrimeNG Galleria ResponsiveAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will see the Angular PrimeNG Galleria Responsive. Galleria in Angular PrimeNG is 4 min read Angular PrimeNG Galleria FullScreenAngular PrimeNG is an open-source UI component library for Angular Applications. Using the components provided by Angular PrimeNG, one can create stunning and responsive angular applications. In this post, we will see Angular PrimeNG Galleria FullScreen. Galleria is an advanced component to display 4 min read Angular PrimeNG Galleria AutoPlayAngular PrimeNG is an open-source UI component library for Angular Applications. Using the components provided by Angular PrimeNG, one can create stunning and responsive angular applications. In this article, we will see Angular PrimeNG Galleria AutoPlay. Galleria is an advanced component to display 3 min read Angular PrimeNG Galleria CaptionAngular PrimeNG is an open-source UI component library for Angular Applications. Using the components provided by Angular PrimeNG, one can create stunning and responsive angular applications. In this post, we will see Angular PrimeNG Galleria Caption. Galleria is an advanced component to display ima 4 min read Image ComponentAngular PrimeNG Image ComponentAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. It provides a lot of templates, components, theme design, an extensive icon library, and much more. 4 min read Angular PrimeNG Image BasicAngular PrimeNG is an open-source UI component library for Angular Applications. Using the components provided by Angular PrimeNG, one can create stunning and responsive angular applications. In this post, we will see Angular PrimeNG Image Basic. The Image component is used to show a single image to 3 min read Angular PrimeNG Image PreviewAngular PrimeNG is an open-source UI component library for Angular Applications. Using the components provided by Angular PrimeNG, one can create stunning and responsive angular applications. In this post, we will see Angular PrimeNG Image Preview. The Image component is used to show a single image 3 min read Angular PrimeNG Image Indicator TemplatingAngular PrimeNG is an open-source UI component library for Angular Applications. Using the components provided by Angular PrimeNG, one can create stunning and responsive angular applications. In this post, we will see Angular PrimeNG Image Indicator Templating. The Image Component is used to show a 3 min read Angular PrimeNG Image PropertiesAngular PrimeNG is an open-source UI component library for Angular Applications. Using the components provided by Angular PrimeNG, one can create stunning and responsive angular applications. In this article, we will see Angular PrimeNG Image Properties. The Image component is used to show a single 3 min read Angular PrimeNG Image EventsAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will know how to use Angular PrimeNG Image Events. The Image Component is used t 3 min read Angular PrimeNG Image TemplatesAngular PrimeNG is an open-source library that consists of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will discuss Angular PrimeNG Image Templates. The Image Component is used to show an 3 min read Angular PrimeNG Image StylingAngular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. It provides a lot of templates, components, theme design, an extensive icon library, and much more. 3 min read Like