molinet
molinet

Reputation: 276

Aura controller action.setParams to User.ContactId

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

Upvotes: 0

Views: 332

Answers (1)

Sudarshan
Sudarshan

Reputation: 363

<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

Upvotes: 0

Related Questions