Компоненты PrimeNG
InputNumber

Числовой инпут

PrimeNG/InputNumber (opens in a new tab)

Инпут для ввода чисел.

С чего начать

Подключите модуль

import { InputNumberModule } from 'primeng/inputnumber';

В .ts файле

import { Component, OnInit } from '@angular/core';
 
@Component({
  selector: 'app-prime-inputnumber',
  templateUrl: './prime-inputnumber.component.html',
  styleUrls: ['./prime-inputnumber.component.scss']
})
export class PrimeInputnumberComponent implements OnInit {
 
  constructor() { }
 
  value1: number = 42723;
  value2: number = 58151;
  value3: number = 2351.35;
  value4: number = 50;
  value5: number = 151351;
  value6: number = 115744;
  value7: number = 635524;
  value8: number = 732762;
  value9: number = 1500;
  value10: number = 2500;
  value11: number = 4250;
  value12: number = 5002;
  value13: number = 20;
  value14: number = 50;
  value15: number = 10;
  value16: number = 20;
  value17: number = 20;
  value18: number = 10.50;
  value19: number = 25;
  value20: number = 50;
 
  valueXs = 1000;
  valueSm = 3000;
  valueDe = 5000;
  valueLg = 7000;
  ngOnInit(): void {
  }
}

Встройте компонент с помощью тэга p-inputNumber.

<p-inputNumber inputId="integeronly" [(ngModel)]="value1"></p-inputNumber>

Numerals

Integer OnlyWithout GroupingMin-Max Fraction DigitsMin-Max BoundariesUser LocaleUnited States LocaleGerman LocaleIndian Locale

Numerals

Currency

United StatesGermanyIndiaJapan

Prefix and Suffix

Buttons

StackedHorizontal with StepMin-Max Boundaries

Vertical

Readonly

Для включения свойства readonly передайте свойство в компонент таким образом: [readonly]="true". Поле будет активно, но вписать в него текст не получится.Float Label

Float Label

Размеры

Extra smallSmallDefaultLarge

Свойства

NameTypeDefaultDescription
valuenumbernullValue of the component.
formatbooleantrueWhether to format the value.
showButtonsbooleanfalseDisplays spinner buttons.
buttonLayoutstringstackedLayout of the buttons, valid values are "stacked" (default), "horizontal" and "vertical".
incrementButtonClassstringnullStyle class of the increment button.
decrementButtonClassstringnullStyle class of the decrement button.
incrementButtonIconstringpi pi-chevron-upStyle class of the increment button.
decrementButtonIconstringpi pi-chevron-downStyle class of the decrement button.
localestringnullLocale to be used in formatting.
localeMatcherstringbest fitThe locale matching algorithm to use. Possible values are "lookup" and "best fit"; the default is "best fit". See <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation"&gt;Locale (opens in a new tab) Negotation</a> for details.
modestringdecimalDefines the behavior of the component, valid values are "decimal" and "currency".
prefixstringnullText to display before the value.
suffixstringdecimalText to display after the value.
currencystringnullThe currency to use in currency formatting. Possible values are the <a href="https://www.currency-iso.org/en/home/tables/table-a1.html"&gt;ISO (opens in a new tab) 4217 currency codes</a>, such as "USD" for the US dollar, "EUR" for the euro, or "CNY" for the Chinese RMB. There is no default value; if the style is "currency", the currency property must be provided.
currencyDisplaystringsymbolHow to display the currency in currency formatting. Possible values are "symbol" to use a localized currency symbol such as €, ü"code" to use the ISO currency code, "name" to use a localized currency name such as "dollar"; the default is "symbol".
useGroupingbooleantrueWhether to use grouping separators, such as thousands separators or thousand/lakh/crore separators.
minFractionDigitsnumbernullThe minimum number of fraction digits to use. Possible values are from 0 to 20; the default for plain number and percent formatting is 0; the default for currency formatting is the number of minor unit digits provided by the <a href="https://www.currency-iso.org/en/home/tables/table-a1.html"&gt;ISO (opens in a new tab) 4217 currency code list</a> (2 if the list doesn't provide that information).
maxFractionDigitsnumbernullThe maximum number of fraction digits to use. Possible values are from 0 to 20; the default for plain number formatting is the larger of minimumFractionDigits and 3; the default for currency formatting is the larger of minimumFractionDigits and the number of minor unit digits provided by the <a href="https://www.currency-iso.org/en/home/tables/table-a1.html"&gt;ISO (opens in a new tab) 4217 currency code list</a> (2 if the list doesn't provide that information).
minnumbernullMininum boundary value.
maxnumbernullMaximum boundary value.
stepnumber1Step factor to increment/decrement the value.
allowEmptybooleantrueDetermines whether the input field is empty.
stylestringnullInline style of the component.
styleClassstringnullStyle class of the component.
inputIdstringnullIdentifier of the focus input to match a label defined for the component.
inputStylestringnullInline style of the input field.
inputStyleClassstringnullStyle class of the input field.
placeholderstringnullAdvisory information to display on input.
sizenumbernullSize of the input field.
maxlengthnumbernullMaximum number of character allows in the input field.
tabindexnumbernullSpecifies tab order of the element.
disabledbooleanfalseWhen present, it specifies that the element should be disabled.
readonlybooleanfalseWhen present, it specifies that an input field is read-only.
titlestringnullTitle text of the input text.
ariaLabelstringnullUsed to define a string that labels the input element.
ariaRequiredbooleanfalseUsed to indicate that user input is required on an element before a form can be submitted.
namestringnullName of the input field.
autocompletestringnullUsed to define a string that autocomplete attribute the current element.

События

NameParametersDescription
onFocusevent: Browser eventCallback to invoke when input receives focus.
onBlurevent: Browser eventCallback to invoke when input loses focus.
onInputevent.originalEvent: Browser event<br>event.value: New valueCallback to invoke when the value is entered.

Методы

NameParametersDescription
getFormatter-Returns Intl.NumberFormat object.

Стилизация

NameElement
p-inputnumberContainer element
p-inputnumber-stackedContainer element with stacked buttons.
p-inputnumber-horizontalContainer element with horizontal buttons.
p-inputnumber-verticalContainer element with vertical buttons.
p-inputnumber-inputInput element
p-inputnumber-buttonInput element
p-inputnumber-button-upIncrement button
p-inputnumber-button-downDecrement button
p-inputnumber-button-iconButton icon