• Daryn Aucoin 1
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi All,

I was taking the 'Handling Actions with Controllers' challenge under Lightning Component Basic and got stuck and not sure where I am wrong.
Challenge was
Add a button to the campingListItem component that when clicked, marks the item as packed.
  • Add a button labeled Packed! that calls the packItem controller function when clicked.
  • The controller action marks the item attribute as packed, updates the item value provider and disables the button.
I have created the component and was working on controller.js but always getting an error, below are my code
<aura:component >
    <aura:attribute name="item" type="Camping_Item__c" required="false"/>
    
    <p>Name:
        <ui:inputText value="{!v.item.Name}" />
    </p>
    
    <p>Price:
        <ui:inputCurrency value="{!v.item.Price__c}" />
    </p>
    
    <p>Quantity:
        <ui:inputNumber value="{!v.item.Quantity__c}" />
    </p>
    
    <p>Packed:
        <ui:inputCheckbox value="{!v.item.Packed__c}"/>
    </p>
    
    <ui:button label="Packed!" press="{!c.packItem}" />
    
</aura:component>
controller.js
({
	packItem : function(component, event, helper) {
		event.getSource().set('v.disabled', true);
        component.set("v.item.Packed__c", true);
    }
})
I have set required=false on campingListItem due to which I can add my component to my App without provided any value
campingListItemApp:
<aura:application >
	<c:campingListItem />
</aura:application>

but everytime I run my package I am getting an error :
User-added image

Can anyone explain why I am getting this error and if possible can provide me a solution.

Thank in Advance.