You need to sign in to do that
Don't have an account?
Lightning Components Basic: "Value number out of range for numberformat options property style"
I'm doing Lightning Components Basic - Input Data Using Forms, and I am running into an error I can't figure out.
I've reduced it here to the minimum code I can for reproducing the error, and I'm hoping someone can explain to me what's causing it.
campingApp.app
campingOneNewItem.cmp
campingListItemSimple.cmp
campingOneNewItemController.js
campingApp renders like this:

But when I click Add quantity I get an error:
Sorry to interrupt
This page has an error. You might just need to refresh it. Action failed: lightning:formattedNumber$controller$init [Value number out of range for numberformat options property style] Failing descriptor: {lightning:formattedNumber$controller$init}

I'm pretty sure that somehow Quantity__c is being cast to string, but even when I explicitly cast it to number before calling component.set I get this error.
I've reduced it here to the minimum code I can for reproducing the error, and I'm hoping someone can explain to me what's causing it.
campingApp.app
<aura:application extends="force:slds"> <c:campingOneNewItem /> </aura:application>
campingOneNewItem.cmp
<aura:component > <aura:attribute name="items" type="Camping_Item__c[]"/> <aura:attribute name="newItem" type="Camping_Item__c" default="{ 'sObjectType': 'CampingItem__c', 'Quantity__c': 0, 'Price__c': 0 }"/> <form> <lightning:input type="number" label="Quantity" name="campingitemquantity" value="{!v.newItem.Quantity__c}" min="1" aura:id="newcampingitemform" messageWhenRangeUnderflow="Enter an amount that's at least 1"/> <lightning:button label="Add quantity" onclick="{!c.addQuantity}"/> </form> <ol> <aura:iteration items="{!v.items}" var="item"> <li><c:campingListItemSimple item="{!item}"/></li> </aura:iteration> </ol> </aura:component>
campingListItemSimple.cmp
<aura:component > <aura:attribute name="item" type="Camping_Item__c" required="true"/> <h2>Quantity</h2> <p> <lightning:formattedNumber value="{! v.item.Quantity__c}" style="number"/> </p> </aura:component>
campingOneNewItemController.js
({ addQuantity : function(component, event, helper) { // Get current items var items = component.get('v.items'); // Create the new item var newItem = component.get('v.newItem'); // Copy the expense to a new object // THIS IS A DISGUTING, TEMPORARY HACK var newItem = JSON.parse(JSON.stringify(newItem)); // explicitly casting newItem.Quantity__c to Number had no effect: // newItem.Quantity__c = Number(newItem.Quantity__c); items.push(newItem); component.set("v.items", items); } })
campingApp renders like this:
But when I click Add quantity I get an error:
Sorry to interrupt
This page has an error. You might just need to refresh it. Action failed: lightning:formattedNumber$controller$init [Value number out of range for numberformat options property style] Failing descriptor: {lightning:formattedNumber$controller$init}
I'm pretty sure that somehow Quantity__c is being cast to string, but even when I explicitly cast it to number before calling component.set I get this error.
If you look at the "style" attribute here:
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_formattedNumber.htm
You'll see:
"The number formatting style to use. Possible values are decimal, currency, and percent. This value defaults to decimal."
What happens if you update it to a valid value?
All Answers
If you look at the "style" attribute here:
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_formattedNumber.htm
You'll see:
"The number formatting style to use. Possible values are decimal, currency, and percent. This value defaults to decimal."
What happens if you update it to a valid value?
Is there anywhere to learn how to read these error messages?