Aptitude (12) C (2) C++ (10) CSS (1) Data Structure (2) English (7) General (14) HTML (3) Integration (1) Itinerary and Travel Cost (1) Java (29) JQ (5) JS (5) JSP (1) Lightning (14) logical (3) Math (1) Music Notation (17) MySql (4) Network (1) Regex (1) salesforce (131) Servlet (4) SF Admin (31) SF Dev (102) SQL (4) SQL_SERVER (1) StudyPoints (2) ytChannels (2) अन्ताक्षरी (4)

How to set all component's attributes value by one call of component.set();

<!--- Lightning Component  ---->
<aura:component>
<aura:attribute name="map" type="Map" default="{str1:null,str2:null,obj:null}"/>
<aura:attribute name="str1" type="String"  default="{!v.map.str1}"/>
 <aura:attribute name="str2" type="String" default="{!v.map.str2}"/>
 <aura:attribute name="obj" type="Contact" default="{!v.map.obj}"/>
</aura:component>




------------Lightning Component Controller--------------------------
fn: function(cmp, event, helper)
    {
        var map=cmp.get("v.map");//top or START of function
           //some logic here
        map['str1']='LastName';
         //some logic here
        map['str2']='Firstname';
        //some logic here
        var obj={"FirstName":"Ram","LastName":'Lakhan'};
        map['obj']=obj;

        cmp.set("v.map",map);// END of function
}

No comments: