Open In App

Angular PrimeNG Form InputNumber Min and Max Boundaries Component

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 learn how to use the Form InputNumber Min and Max Boundaries Component in Angular PrimeNG. We will also learn about the properties, along with their syntaxes that will be used in the code.

The InputNumber component allows a user to input content as a numerical value.



Syntax:

<p-inputNumber
    placeholder="..."
    [min]="..."
    [max]="...">
</p-inputNumber>

 



Angular PrimeNG Form InputNumber Min and Max Boundaries Component Properties:

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: The following project structure will appear after successful installation:

 

ng serve --save

Example 1: In the below code, we will be seeing the demonstration of the Angular PrimeNG Form InputNumber Min and Max Boundaries Component.




<h1 style="color: green">GeeksforGeeks</h1>
<h5>
    Angular PrimeNG Form InputNumber 
    Min and Max Boundaries Component
</h5>
  
<p-inputNumber
    placeholder="67"
    [min]="-1"
    [max]="50">
</p-inputNumber>




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




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 { InputNumberModule }
    from 'primeng/inputnumber';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        InputNumberModule,
        FormsModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }

Output:

 

Example 2: Below is another code example that demonstrates the Angular PrimeNG Form InputNumber Min and Max Boundaries Component.




<h1 style="color: green">GeeksforGeeks</h1>
<h5>
    Angular PrimeNG Form InputNumber 
    Min and Max Boundaries Component
</h5>
  
<p-inputNumber
    placeholder="Input any number"
    [min]="-100"
    [max]="100">
</p-inputNumber>




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




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 { InputNumberModule } 
    from 'primeng/inputnumber';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        InputNumberModule,
        FormsModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }

Output:

 

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


Article Tags :