You need to sign in to do that
Don't have an account?
nagachandra kn
Input data in lightning component.
Hi All,
I am writing a basic lightning component. please find the code below. I am just getting the value from the inputtext component and displaying it on the console. But it is giving me following error. what i m doing wrong.?
controller.
Error which i m getting aftter clicking the button. No error displayed in javascript console.
This page has an error. You might just need to refresh it. Error in $A.getCallback() [Cannot read property 'KNNaga__Amount__c' of null] Failing descriptor: {markup://ui:input}
Thanks in advance.
I am writing a basic lightning component. please find the code below. I am just getting the value from the inputtext component and displaying it on the console. But it is giving me following error. what i m doing wrong.?
<aura:component > <aura:attribute name="newExpense" type="KNNaga__Expense__c" access="public"/> <ui:inputText value="{!v.newExpense.KNNaga__Amount__c}" label="Expense Name" aura:id="Amount"/> <ui:button label="submit" press="{!c.createExpense}"/> </aura:component>
controller.
({ createExpense : function(component, event, helper) { var name = component.find("Amount"); var value = name.get("v.value"); console.log("value::"+value); } })
Error which i m getting aftter clicking the button. No error displayed in javascript console.
This page has an error. You might just need to refresh it. Error in $A.getCallback() [Cannot read property 'KNNaga__Amount__c' of null] Failing descriptor: {markup://ui:input}
Thanks in advance.
give default value to attribute then your console display the value of input box
thanks
let me inform if it helps you
sfdcmonkey.com
All Answers
give default value to attribute then your console display the value of input box
thanks
let me inform if it helps you
sfdcmonkey.com
Thanks u . it worked. One quick question.
Do u have specify "default" for each attribute i write ?
we have not need to give default for each attribute its optional but in your case your input field maping with Expense__c custom object so you must define default value if you only write like this (only object body) -:
<aura:attribute name="newExpense" type="Expense__c" default="{}" access="public"/>
then also your compnent work fine .
otherwise its assume object null.
so it always good pratice that when we are map any component field with custom or stand. object then give default value to attribute