Open In App

Angular PrimeNG Form Knob Properties Component

Last Updated : 18 Oct, 2022
Improve
Improve
Like Article
Like
Save
Share
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 the InputNumber component in Angular PrimeNG. We will also learn about the properties, events, methods & styling along with their syntaxes that will be used in the code. 

The knob component is a form component that is used to define a dialer-type knob that contains labels and some data values.

Angular PrimeNG Form Knob Properties Component Properties:

  • size: It is used to set the size of the component in pixels. It is of number data type, the default value is 100.
  • disabled: It specifies that the element should be disabled. It is of the boolean data type, the default value is false.
  • readonly: It is used to specify that the component cannot be edited. It is of the boolean data type, the default value is false.
  • min: It is used to set the minimum boundary value. It is of number data type, the default value is 0.
  • max: It is used to set the maximum boundary value. It is of number data type, the default value is 100.
  • step: It is used to set the step factor to increment/decrement the value. It is of number data type, the default value is null.
  • valueColor: It is used to set the background of the value. It is of string data type, the default value is null.
  • rangeColor: It is used to set the background color of the range. It is of number data type, the default value is null.
  • textColor: It is used to set the color of the value text. It is of number data type, the default value is null.
  • strokeWidth: It is used to set the width of the knob stroke. It is of number datatype, the default value is 14.
  • showValue: It is used to specify whether to show the value inside the knob. It is of the boolean datatype, and the default value is true.
  • valueTemplate: It is used to set the template string of the value. It is of string data type, the default value is value.
  • style: It is used to set the Inline style of the element. It is of object data type, the default value is null.
  • styleClass: It is used to set the Style class of the element. It is of string data type, the default value is null.

 

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: 

 

Example 1: In the below code, we will be using the above properties to demonstrate the use of the Form Knob Properties Component.

  • app.component.html

HTML




<div style="text-align:center">
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
    <h3>
        A computer science portal for geeks
    </h3>
    <h4>
        Angular PrimeNG Form Knob Properties Component
    </h4>
    <h5>disabled</h5>
    <div class="p-grid p-formgrid">
        <div class="p-field p-col-12 p-md-4">
            <p-knob 
                [(ngModel)]="value3" 
                disabled="true">
            </p-knob>
        </div>
    </div>
</div>


  • app.component.ts

Javascript




import { Component } from "@angular/core";
  
@Component({
    selector: "app-root",
    templateUrl: "./app.component.html"
})
export class AppComponent {
    value1: number = 0;
    value2: number = 50;
    value3: number = 75.5;
    value4: number = 10.5;
    value5: number = 40.5;
    value6: number = 60;
    value7: number = 40.5;
}


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


Output:

 

Example 2: In the below code, we will be using the above properties to demonstrate the use of the Form Knob Properties Component.

  • app.component.html

HTML




<div style="text-align:center">
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
    <h3>
        A computer science portal for geeks
    </h3>
    <h4>
        Angular PrimeNG Form Knob Properties Component
    </h4>
  
    <div class="p-grid p-formgrid">
        <div class="p-field p-col-12 p-md-4">
            <p-knob 
                [(ngModel)]="value4">
            </p-knob>
        </div>
    </div>
</div>


  • app.component.ts

Javascript




import { Component } from "@angular/core";
  
@Component({
    selector: "app-root",
    templateUrl: "./app.component.html"
})
export class AppComponent {
    value1: number = 0;
    value2: number = 50;
    value3: number = 75.5;
    value4: number = 10.5;
    value5: number = 40.5;
    value6: number = 60;
    value7: number = 40.5;
}


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


Output:

 

Reference: https://www.primefaces.org/primeng/knob



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads