function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
hemanth tanguturi 10hemanth tanguturi 10 

trailhead Challenge in lightning : lightning components basics module-->Handle action with controller-->Mark Item as Packed

Hi All,

with below code I have completed the challenge thanks!!...When I tried to add this componet to Application and tried to check the UI part..I got below error, Can some one please let me know what the mistake is???

Something has gone wrong. [NoErrorObjectAvailable] Aura.loadComponent(): Failed to initialize application. An internal server error has occurred Error ID: 991118890-131685 (-1741317831) . Please try again.

APP:

<aura:application >
    <c:campingListItem />
</aura:application>


COMPONENT:

<aura:component >

    <aura:attribute name="item" type="Camping_Item__c" required="true"/>
    <ui:outputText value="{!v.item}"/>
    <ui:outputText value="{!v.item.Name}"/>
    <ui:outputCheckbox value="{!v.item.Packed__c}"/>
    <ui:outputCurrency value="{!v.item.Price__c}"/>
    <ui:outputNumber value="{!v.item.Quantity__c}"/>
    
    <ui:button label="packed!" press="{!c.packItem}" > 
    </ui:button>
</aura:component>


CONTROLLER:
({
    packItem: function(component, event, helper) {
        var a = component.get("v.item",true);
       
        a.Packed__c = true;
        component.set("v.item",a);
        var btnClicked = event.getSource();
        btnClicked.set("v.disabled",true);
    }
})


Thanks
Bhavin Mehta 20Bhavin Mehta 20
Please keep some default value while defining attribute to solve this issue.

 <aura:attribute name="item"    type="Camping_Item__c" required="true"
                     default="{Name:'ABC', Price__c:100, Quantity__c:1, Packed__c:false}"/>