Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Angular PrimeNG Form Slider Min-Max Component

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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 the Slider Min-Max Component in Angular PrimeNG.

The Slider Component is an element of input that accepts numerical inputs.

Syntax:

<p-slider 
    [(ngModel)]="..." 
    [min]="..."
    [max]="...">
</p-slider>

 

Angular PrimeNG Form Slider Min-Max properties:

  • min: It is used to set the Minimum boundary value, It is of number data type, and the default value is 0.
  • max: It is used to set the Maximum boundary value, It is of number data type, and the default value is 100.

Creating Angular Application & module installation:

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

ng new appname

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

cd appname

Step 3: Install PrimeNG in your given directory.

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

Project Structure: It will look like the following.

 

To run the above file run the below command:

ng serve --save

Example 1: This basic example shows how to use the Angular PrimeNG Form Slider Min-Max Component using the min attribute.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Slider Min-Max</h5>
<h3>Slider Value: {{gfg}}</h3>
<p-slider [(ngModel)]="gfg" [min]="40"></p-slider>


  • app.component.ts:

Javascript




import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html'
})
  
export class AppComponent { }


  • app.module.ts:

Javascript




import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {FormsModule} from '@angular/forms';
import { BrowserAnimationsModule } 
    from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import {SliderModule} from 'primeng/slider';
import {InputTextModule} from 'primeng/inputtext';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        SliderModule,
        InputTextModule,
        FormsModule
    ],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ]
})
  
export class AppModule { }


Output:

 

Example 2: This is another example that shows how to use the Angular PrimeNG Form Slider Min-Max Component using the max attributes.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Slider Min-Max</h5>
<input type="number" pInputText [(ngModel)]="gfg"/>
<br/><br/>
<p-slider [(ngModel)]="gfg" [min]="50" [max]="70"></p-slider>


  • app.component.ts:

Javascript




import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html'
})
  
export class AppComponent { }


  • app.module.ts:

Javascript




import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {FormsModule} from '@angular/forms';
import { BrowserAnimationsModule } 
    from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import {SliderModule} from 'primeng/slider';
import {InputTextModule} from 'primeng/inputtext';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        SliderModule,
        InputTextModule,
        FormsModule
    ],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ]
})
  
export class AppModule { }


Output:

 

Reference: https://primefaces.org/primeng/slider


My Personal Notes arrow_drop_up
Last Updated : 22 Nov, 2022
Like Article
Save Article
Similar Reads
Related Tutorials