md2
Version:
Angular2 based Material Design components, directives and services are Accordion, Autocomplete, Chips(Tags), Collapse, Colorpicker, Data Table, Datepicker, Dialog(Modal), Menu, Multiselect, Select, Tabs, Tags(Chips), Toast and Tooltip.
9 lines • 680 B
JavaScript
/** Coerces a data-bound value (typically a string) to a number. */
/** Coerces a data-bound value (typically a string) to a number. */ export function coerceNumberProperty(value, fallbackValue) {
if (fallbackValue === void 0) { fallbackValue = 0; }
// parseFloat(value) handles most of the cases we're interested in (it treats null, empty string,
// and other non-number values as NaN, where Number just uses 0) but it considers the string
// '123hello' to be a valid number. Therefore we also check if Number(value) is NaN.
return isNaN(parseFloat(value)) || isNaN(Number(value)) ? fallbackValue : Number(value);
}
//# sourceMappingURL=number-property.js.map