Struggling to dynamically change the color of my button, any suggestions?
<a class="button buttonaquacss button-mini button-aqua text-right pull-right" (click)='send(button,detail.profile_id)' #button [ngStyle]="{'background-color': color}"><span><i class="icon-plus-sign"></i>{{detail.innerHTML}}</span></a>
if (detail.connection_status == '') {
detail.innerHTML = "connect";
this.color = "red";
}
send(button, index): void {
var str = localStorage.getItem('social');
var loc = JSON.parse(str);
var id = loc.profile_id;
var formdata = { received_id: index, sent_id: id }
this.color = 'blue';
var headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded')
this.http.post('http://localhost/a2server/index.php/requests/sendrequest/', formdata, { headers: headers })
.subscribe(
response => {
if (response.json().error_code == 0) {
button.innerHTML = "Pending";
button.disabled = true;
this.color = "#127bdc";
}
else {
button.innerHTML = "Unable to send request";
}
});
}
Looking for assistance on dynamically changing button color.