Change bar-button color with Angular style

I’m trying to change color of .bar-button color with following code:

this.navbarEle.querySelector('page-content .bar-button').style.color = this.colors[color].fg;

it won’t change color of bar-button, although the following code will work for other icons in navbar:

this.navbarEle.querySelector('ion-icon').style.color = this.colors[color].fg;

How can I solve it?

Are you in Angular? If so, this code pattern is discouraged. Instead of reaching into the DOM yourself, let Angular do it. So use the color input of the ion button component, or use ngStyle.

1 Like