Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
188
rated 0 times [  195] [ 7]  / answers: 1 / hits: 23933  / 8 Years ago, thu, january 5, 2017, 12:00:00

How do you change the text of a <button> when that button is clicked in angular2?



For example, changing the button text from Save to Saving... and then also set it to be disabled.



I know how to do this in AngularJS, jQuery, and plain JS, and I have some ideas on how to do this in Angular2, but I wanted to make sure I'm not doing it in some outdated or convoluted way when it comes to Angular2.


More From » angular

 Answers
5
<button (click)=setSaving($event.target, 'saving')>save</button>


and then in your component:



setSaving(element, text){
element.textContent = text;
element.disabled = true;
}


You can also set the properties using the Renderer


[#59450] Tuesday, January 3, 2017, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jelani

Total Points: 473
Total Questions: 99
Total Answers: 99

Location: Cape Verde
Member since Fri, Nov 27, 2020
4 Years ago
;