Angular PrimeNG InputText 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 know how to use the InputText component in angular primeNG. Let’s learn about the properties, styling & their syntaxes that will be used in the code.
InputTextArea component: It is an element that is used to make a text field with multi-line input support.
- disabled: We can set the input component to be disabled. It is of a boolean data type & the default value is false.
- p-inputtext: It is a directive & applied to the text input field.
<input type="text" pInputText />
Model Binding: ngModel directive is used to bind the model.
<input type="text" pInputText [(ngModel)]="property"/>
Size: In addition to the regular sizes, there are more than 2 sizes that are available, add p-inputtext-sm for small text input & add p-inputtext-lg for large text input. These classes must be used to change the size of the particular input field.
For smaller input text
<input type="text" pInputText class="p-inputtext-sm">
For larger input text
<input type="text" pInputText class="p-inputtext-lg">
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.
- Step 3: Install PrimeNG in your given directory.
npm install primeng --save npm install primeicons --save
Project Structure: It will look like the following.
Example 1: This is the basic example that shows how to use InputText component
Example 2: In this example, we will know how to set the size of the InputText component.
Please Login to comment...