Changing the font-size of the field with value coming from the database

Asked

Viewed 36 times

-1

Good morning, I get from the database a vrFonte="x" with a value x, this value that comes to me will be the size of the input source, is it possible to make the field assume the size of this source that comes from the database? if yes, how ? Thank you

1 answer

0


You can use the [ngStyle] as function return, example:

vrFonte: number
setStyles() {
  let styles = {
    'font-size': this.vrFonte || '13px'
  };
  return styles;
}

 //OBS: 'font-size': this.vrFonte || '13px' caso vrFonte seja `undefined` ele atribuira 13px ao input.

there in your input you would put :

<input type="text" [ngStyle]="setStyles()">

Another way to do it would be to use angular style bind:

<input type="text" [style.font-size.px]="{{ vrFonte }}">

  • It worked, but the value is not changed pq by default the ion-input has a font-size ! Important, there is the option to take this Important or add one to this first example you sent ?

  • Try to do:': ${this.vrFonte } !important , or if the 'px' next to the value of the database use, 'font-size': ${this.vrFonte }px !important .

  • px does not come together, I added it to work though, when I put ! It’s not right

Browser other questions tagged

You are not signed in. Login or sign up in order to post.