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
VijayNiVijayNi 

APPLICATION markup://c:Lightningapp is missing required attribute 'input1'

Hi ,

I am getting the below error while creating a simple calcultor app . can anyone please help me .

calculator component

<aura:component >
    <aura:attribute name="input1" type ="integer" required ="true" description = "For first Input" /> 
    <aura:attribute name="input2" type ="integer" required ="true" description = "For second Input" />
    <lightning:input type="number" value="{!v.input1}" label="Please enter a value " required ="true" /> 
     <lightning:input type="number" value="{!v.input2}" label="Please enter a value " required ="true" />

    <lightning:button variant="Component Methods" label="add"  onclick="{! c.doAdd}"/>
    <lightning:button variant="Component Methods" label="sub"  onclick="{! c.dosub}"/>
    <lightning:button variant="Component Methods" label="Multiply"  onclick="{! c.doMul}"/>
    <lightning:button variant="Component Methods" label="Divide"  onclick="{! c.doDiv}"/>


          </aura:component>

controllerr :

({
    doAdd : function(component, event, helper) {
        var number1 = component.get('v.input1');
        var number2 = component.get('v.input2');
        alert(parseInt(number1) + parseInt(number2));
        
    },
    
    
    dosub : function(component, event, helper) {
         var number1 = component.get('v.input1');
        var number2 = component.get('v.input2');
        
    },
    
    doMul : function(component, event, helper) {
         var number1 = component.get('v.input1');
        var number2 = component.get('v.input2');
        
    },
    doDiv : function(component, event, helper) {
         var number1 = component.get('v.input1');
        var number2 = component.get('v.input2');
    },
    
})

Application :


<aura:application >
    <c:calculator />
    
</aura:application>
Best Answer chosen by VijayNi
Abhishek BansalAbhishek Bansal
Hi Vijay,

You have written component name twice, please remove one. Use the below code:
<aura:application >
    
    <c:calculator input1="2" input2="5" />
    
</aura:application>

Thanks,
Abhishek Bansal.

All Answers

Abhishek BansalAbhishek Bansal

Hi Vijay,

As stated in the error, your component is missing the required attributes. You need to pass the attributes values that are required while referencing the component from anywhere.
Please change the application code like below:
<aura:application >
    <c:calculator input1="2" ....add all required attribute values here />
    
</aura:application>

Thanks,
Abhishek Bansal

VijayNiVijayNi
Hi Abhishek,

I tried to change it  like the below still i am gettng error . i have only 2 attributes input 1 and input 2

<aura:application >
    <c:calculator />
    
    <c:calculator input1="2" input2="5" />
    
</aura:application>

Thanks
Vijay
Abhishek BansalAbhishek Bansal
Hi Vijay,

You have written component name twice, please remove one. Use the below code:
<aura:application >
    
    <c:calculator input1="2" input2="5" />
    
</aura:application>

Thanks,
Abhishek Bansal.
This was selected as the best answer
VijayNiVijayNi
Thanks Abhishek,

It worked fine .

Thanks,
Vijay.