Open In App

Angular PrimeNG Galleria Properties

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 be seeing Angular PrimeNG Galleria Component.

Angular PrimeNG Galleria is an advanced content gallery component. It is used for displaying images in an attractive manner. Let us learn about this using some examples.



Angular PrimeNG Galleria Component Properties:

 



Syntax:

<p-galleria [numVisible]="..." [value]="...">
   <ng-template pTemplate="item" let-item>
       <img [src]="..." [alt]="..." [title]="..." 
           style="width: 50%;" />
   </ng-template>
   <ng-template pTemplate="thumbnail" let-item width="50%">
       <div class="grid grid-nogutter justify-content-center">
           <img [src]="..." [alt]="..." [title]="..." width=80% />
       </div>
   </ng-template>
</p-galleria>

Creating Angular application & module installation:

Step 1: Install the Angular CLI

npm install - g @angular/cli

Step 2: Create an Angular application using the following command.

ng new appname

Step 3: After creating your project folder i.e. appname, move to it using the following command.

cd appname

Step 4: Install PrimeNG in your given directory.

npm install primeng --save
npm install primeicons --save

Project Structure: The project structure will look like the following image:

 

Example 1: In this example, we will learn about Galleria Properties like values, numVisible, autoplay, circular, showThumbnails.

app.component.html




<div id="GFG">
    <h1 style="color:green;">GeeksforGeeks</h1>
    <h2>Angular PrimeNG Galleria Properties</h2>
  
    <div style="width:60%; ">
        <p-galleria [value]="images" [numVisible]="3" 
            [showThumbnails]="true" [circular]="true" 
            [autoPlay]="true">
  
            <ng-template pTemplate="item" let-item>
                <img [src]="item.previewImageSrc" 
                    style="width: 80%;" />
            </ng-template>
            <ng-template pTemplate="thumbnail" let-item>
                <div class="grid grid-nogutter 
                    justify-content-center">
                    <img [src]="item.thumbnailImageSrc" width=80% />
                </div>
            </ng-template>
        </p-galleria>
    </div>
</div>

app.component.ts




import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent {
    title = 'GFG';
  
    images: any[] = [
        {
            previewImageSrc:
            thumbnailImageSrc:
            alt: 'Description for Image 1',
            title: 'Title 1'
        },
        {
            previewImageSrc:
            thumbnailImageSrc:
            alt: 'Description for Image 2',
            title: 'Title 2'
        },
        {
            previewImageSrc:
            thumbnailImageSrc:
            alt: 'Description for Image 3',
            title: 'Title 3'
        },
        {
            previewImageSrc:
            thumbnailImageSrc:
            alt: 'Description for Image 4',
            title: 'Title 4'
        },
    ];
}

app.module.ts




import { NgModule } from '@angular/core';
import { BrowserModule }
    from '@angular/platform-browser';
import { GalleriaModule } from 'primeng/galleria';
import { AppComponent } from './app.component';
@NgModule({
    declarations: [
        AppComponent,
    ],
    imports: [
        BrowserModule,
        GalleriaModule
    ],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule { }

Output:

 

Example 2: In this example, we will learn about Galleria properties like values, showIndicators, indicatorsPosition ,autoplay ,circular,thumbnailsPosition, indicatorsPosition

app.component.html




<div id="GFG">
    <h1 style="color:green">GeeksforGeeks</h1>
    <h2>Angular PrimeNG Galleria Properties</h2>
  
    <div style="width:60%; ">
        <p-galleria [value]="images" 
            [numVisible]="3" [showThumbnails]="true" 
            [circular]="true" [autoPlay]="true"
            thumbnailsPosition="top" [showIndicators]="true" 
            indicatorsPosition="top">
  
            <ng-template pTemplate="item" let-item>
                <img [src]="item.previewImageSrc" style="width: 80%;" />
            </ng-template>
            <ng-template pTemplate="thumbnail" let-item>
                <div class="grid grid-nogutter justify-content-center">
                    <img [src]="item.thumbnailImageSrc" width=80% />
                </div>
            </ng-template>
        </p-galleria>
    </div>
</div>

app.component.ts




import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent {
    title = 'GFG';
  
    images: any[] = [
        {
            previewImageSrc:
            thumbnailImageSrc:
            alt: 'Description for Image 1',
            title: 'Title 1'
        },
        {
            previewImageSrc:
            thumbnailImageSrc:
            alt: 'Description for Image 2',
            title: 'Title 2'
        },
        {
            previewImageSrc:
            thumbnailImageSrc:
            alt: 'Description for Image 3',
            title: 'Title 3'
        },
        {
            previewImageSrc:
            thumbnailImageSrc:
            alt: 'Description for Image 4',
            title: 'Title 4'
        },
    ];
}

app.module.ts




import { NgModule } from '@angular/core';
import { BrowserModule } 
    from '@angular/platform-browser';
import { GalleriaModule } from 'primeng/galleria';
import { AppComponent } from './app.component';
@NgModule({
    declarations: [
        AppComponent,
    ],
    imports: [
        BrowserModule,
        GalleriaModule
    ],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule { }

Output:

 

Reference: http://primefaces.org/primeng/galleria


Article Tags :