0

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}";

molinet
  • 266
  • 3
  • 14

1 Answers1

0
<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

Sudarshan
  • 363
  • 1
  • 9