0

It's sound simple but I'm going nuts here, and I'm simply trying to change the label name in the controller.js file

Here is what I'm doing here, any help?

Component:

<ui:button aura:id = "Btn1" label="Get Password" class="slds-button slds-button_brand" press="{!c.handleClick}" />

Controller JS:

var currentBoatTypeChoice = component.find("Btn1");//.get("v.label");
currentBoatTypeChoice.set('v.label','New Label');
2

I have recently tried to change a label of <ui:button> by myself using component.set() method:

component.find('Btn1').set('v.label', 'New Label');

and it absolutely works. Can you please provide an error message, because it should work and probably the issue is caused by something else?

Since of API version 47.0 <ui:button> is deprecated. Use <lightning:button>, <lightning:buttonIcon>, or <lightning:buttonIconStateful> instead.

0

You can create an attribute and put it in the button's label. This way, you can simply modify the attribute's value in the js, and it will change in the button as well.

Component:

<aura:attribute name="buttonLabel" type="String" default="Get password" />
<ui:button aura:id = "Btn1" label="{!v.buttonLabel}" class="slds-button slds-button_brand" press="{!c.handleClick}" />

Controller.js

component.set("v.buttonLabel", "New label");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.