Open In App

Angular PrimeNG Galleria FullScreen

Angular 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 images in an attractive manner. When the galleria component is in fullscreen mode, a blackish mask covers the whole page and the content is displayed over that mask.



Angular PrimeNG Galleria FullScreen Properties:

 



Syntax:

<p-galleria 
    [value]="..." 
    [fullScreen]="..."
    [(visible)]="...">

    <ng-template pTemplate="item" let-x>
        ...
    </ng-template>
</p-galleria>

Creating Angular application and Installing the Modules:

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

ng new myapp

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

cd myapp

Step 3: Install PrimeNG in your given directory.

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

Project Structure: After completing the above steps, the structure will look like the following.

Project Structure

Example 1: This is a basic example showing how to display the galleria component in fullscreen with thumbnails.




<h2 style="color: green">GeeksforGeeks</h2>
<h3>Angular PrimeNG Galleria FullScreen</h3>
  
<p-galleria 
    [value]="img" 
    [containerStyle]="{'max-width': '500px'}"
    [fullScreen]="true"
    [(visible)]="isVisible">
  
    <ng-template pTemplate="item" let-img>
        <img 
            [src]="img.URL" 
            style="width: 100%; display: block;" />
    </ng-template>
  
    <ng-template pTemplate="thumbnail" let-img>
        <img 
            [src]="img.URL" 
            style="width: 100px; display: block;" />
    </ng-template>
</p-galleria>
  
<p-button 
    label="Show FullScreen" 
    (click)="isVisible = true">
</p-button>




import { Component } from '@angular/core';
  
interface GalleriaImage {
    URL: String;
}
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
})
export class AppComponent {
    img: GalleriaImage[] = [];
    isVisible = false;
  
    ngOnInit() {
        this.img = [
            {
                URL:
            },
            {
                URL:
            },
            {
                URL:
            },
            {
                URL:
            },
            {
                URL:
            },
        ];
    }
}




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

Output:

 

Example 2: This is a basic example showing how to display the galleria component in fullscreen without thumbnails and with autoplay on.




<h2 style="color: green">GeeksforGeeks</h2>
<h3>Angular PrimeNG Galleria FullScreen</h3>
  
<p-galleria 
    [value]="img" 
    [containerStyle]="{'max-width': '500px'}"
    [fullScreen]="true"
    [autoPlay]="true"
    [transitionInterval]="1500"
    [showThumbnails]="false"
    [(visible)]="isVisible">
  
    <ng-template pTemplate="item" let-img>
        <img 
            [src]="img.URL" 
            style="width: 100%; display: block;" />
    </ng-template>
</p-galleria>
  
<p-button 
    label="Show FullScreen" 
    (click)="isVisible = true">
</p-button>




import { Component } from '@angular/core';
  
interface GalleriaImage {
    URL: String;
}
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
})
  
export class AppComponent {
    img: GalleriaImage[] = [];
    isVisible = false;
  
    ngOnInit() {
        this.img = [
            {
                URL: 
            },
            {
                URL: 
            },
            {
                URL:
            },
            {
                URL: 
            },
            {
                URL: 
            }
        ];
    }
}




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

Output:

 

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


Article Tags :