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
shraddha vasu 4shraddha vasu 4 

Getting error while previewing the lightning app.

I am new to salesforce.I have created lightning app  with no error and when I have tried to preview it I am getting error.Not understanding what it is.Please help me out.
Below are the details of my code and error:-

My lightning component :-myFirstLightComp.cmp
<aura:component>
  <aura:attribute  name="first_name" type="String" default="shraddha"/>
  <aura:attribute  name="last_name" type="String" default="vasu" />
  <aura:attribute name="result_us_style" type="String" />

  <ui:inputText label="Enter your first name" value="{!v.first_name}" />
  <ui:inputText label="Enter your last name" value="{!v.last_name}" />
  <br />
  <ui:button  label="submit" press="{!c.doSubmit}" />
  <br />

  <ui:outputText value="{!v.result_us_style}" />
</aura:component>

My lightning controller:- myFirstLightCompController.js
 ({
    doSubmit: function(component, event, helper) {
        console.log(----Start of doSubmit----);
            var firstname =component.get("v.first_name");
            var lastname=component.get("v.last_name");

            var usStyleName=firstname +', '+lastname;

            component.set("v.result_us_style" , usStyleName);

            console.log("*******Operation success*******and******Result*********"+usStyleName);

        console.log(----End of doSubmit----);
        
    }
})

My lightning App:-myFirstLightApp.app

<aura:application>
    <c:myFirstLightComp />
</aura:application>     

I have registered the domain for this also.

This is the error I am getting while previewing the lightning app.
Thanks in advance!!!
Best Answer chosen by shraddha vasu 4
Khan AnasKhan Anas (Salesforce Developers) 
Hi Shraddha,

Greetings to you!

You forget to add double quotes in console.log. Please try below code:

Controller:
({
    doSubmit: function(component, event, helper) {
        console.log("----Start of doSubmit----");
        var firstname =component.get("v.first_name");
        var lastname=component.get("v.last_name");
        
        var usStyleName=firstname +', '+lastname;
        
        component.set("v.result_us_style" , usStyleName);
        
        console.log("*******Operation success*******and******Result*********"+usStyleName);
        
        console.log("----End of doSubmit----");
        
    }
})

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi Shraddha,

Greetings to you!

You forget to add double quotes in console.log. Please try below code:

Controller:
({
    doSubmit: function(component, event, helper) {
        console.log("----Start of doSubmit----");
        var firstname =component.get("v.first_name");
        var lastname=component.get("v.last_name");
        
        var usStyleName=firstname +', '+lastname;
        
        component.set("v.result_us_style" , usStyleName);
        
        console.log("*******Operation success*******and******Result*********"+usStyleName);
        
        console.log("----End of doSubmit----");
        
    }
})

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
This was selected as the best answer
shraddha vasu 4shraddha vasu 4
Hi Anas,

Thanks much!!
It worked :-) 
Yeah, I forgot to add double quotes there.

Regards,
Shraddha