You need to sign in to do that
Don't have an account?
VSK98
Getting Aura.loadComponent(): Failed to initialize application. error
Hi All,
I have created the Single Page with Input text, Button & Output text field. The user enters some value in a text box after clicking on the button the output shows in below. But I am getting an error. Pls find the snippet code below
JS Controller:
Error:
Pls help me on this.
Adv Thanks,
VSK98
I have created the Single Page with Input text, Button & Output text field. The user enters some value in a text box after clicking on the button the output shows in below. But I am getting an error. Pls find the snippet code below
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" > <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <div class="row"> <h2 class="header">Basic Input Text</h2> <lightning:input aura:id="text" name="input1" label="Enter some text" /> <!-- Brand variant: Identifies the primary action in a group of buttons --> <lightning:button variant="brand" label="Brand action" title="Brand action" onclick="{! c.handleClick }" /> </div> You entered: <ui:outputText aura:id="ou"/> </aura:component>
JS Controller:
({ doInit : function(component, event, helper) { }, handleClick : function(component, event, helper) { var ip = component.find("text"); var op = ip.get("v.value"); alert(op); var ot = component.find("ou"); ot.set("v.value",op); } })
Error:
Pls help me on this.
Adv Thanks,
VSK98
You need to specify the "VALUE" attribute in ui:outputText tag like below.
All Answers
Please find the correct code below :-
<aura:component implements="force:appHostable" access="global" >
<aura:attribute name="TestValue" type="String" default=""/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<div class="row">
<h2 class="header">Basic Input Text</h2>
<lightning:input aura:id="text" name="input1" label="Enter some text" value="{!v.TestValue}"/>
<!-- Brand variant: Identifies the primary action in a group of buttons -->
<lightning:button variant="brand" label="Brand action" title="Brand action" onclick="{! c.handleClick }" />
</div>
<lightning:input aura:id="ou"
label="You entered:"
/>
</aura:component>
({
doInit : function(component, event, helper) {
},
handleClick : function(component, event, helper) {
var ip = component.find("text");
var op = ip.get("v.value");
alert(op);
var ot = component.find("ou");
ot.set("v.value",op);
}
})
You were making mistake in "<ui:outputText aura:id="ou"/> " line.
Kindly mark my solution as the best answer if it helps you.
Regards,
Kuldeep Singh
You need to specify the "VALUE" attribute in ui:outputText tag like below.
Hi VSK98
//Component
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
Note: <lightning:outputField fieldName="Text_Area__c" aura:id="ou" /> usse the component
If this answer is helpful for you please choose the best answer.
Thanks
Akshay
+1 In addition to the other answers, I would like add some more detail. Lightning Components is all about building components that are data driven. In others words, pretty much like other popular front end frameworks(Angular, React etc), the UI mutates or responds to the changes or alterations in the data that the specific element or node is bound to.
In this example, you will not really require any button to actually capture the entered Text and then show it on another place. You could use aura:attribute to capture the value that the User enters and display the value within the aura:attribute on another place. In other words, if this aura:attribute that holds the content in the Text Box is changed, the Lightning Framework automatically does a dirty-checking and updates all the sections of the page or component that uses this attribute to display the new value.
I am getting the below error while previewing the lightning app for this challenge. Please help.
This page has an error. You might just need to refresh it. Aura.loadComponent(): Failed to initialize application. An internal server error has occurred Error ID: 1250118482-128364 (1290644278).
Here is the code :
Application :
<aura:application>
<c:campingListItem/>
</aura:application>
Component Code :
<aura:component >
<aura:attribute name="item" type="TPGRND__Camping_Item__c" required="true"/>
<ui:outputText value="{!v.item.Name}"/>
<ui:outputCheckbox value="{!v.item.TPGRND__Packed__c}"/>
<ui:outputCurrency value="{!v.item.TPGRND__Price__c}"/>
<ui:outputNumber value="{!v.item.TPGRND__Quantity__c}"/>
</aura:component>
<aura:component>
<aura:attribute name="item" type="Camping_Item__c" required="true"/>
<p>Price:
<lightning:formattedNumber value="{!v.item.Price__c}" style="currency"/>
</p>
<p>Quantity:
<lightning:formattedNumber value="{!v.item.Quantity__c}" style="number"/>
</p>
<p>
Name: {!v.item.Name}
</p>
<p>
<lightning:input type="toggle"
label="Packed?"
name="packed"
checked="{!v.item.Packed__c}" />
</p>
</aura:component>
I was facing same error & i tried your code . Its not working
I fixed my error using following code.
<aura:application >
<c:campingListItem item=''/>
</aura:application>
Hope, it will helps.
item='' in the application.