Aura controller action.setParams to User.ContactId

287 Views Asked by At

I'm almost new into working with aura controller implementing javascript. My question is if I can set action.setParams({"variable" : "{!User.ContactId}"}); or do I need to make a workaround to accomplish this.

I'm asking this cause my button worked like this OnClick Javascript:

var contactId = "{!User.ContactId}";

1

There are 1 best solutions below

0
On
<aura:component controller="someController">
   <aura:attribute type="User" name="User"/>
   <button onclick="{!c.onClick}">Cilck Here</button>
</aura:component>

//controller
({ 
    onClick : function (component, event, handler){
         var user = component.get ('v.User');
         var contId = user.ContactId;
    }
})

You can define an attribute in component and access that attribute inside js

while accessing any attribute component.get ('v.User'); here v. represents view