Set width using [ngStyle]

hi guys can i set width using [ngStyle]?
i have a div and i want to set it’s width using [ngStyle]. can i do that?
changing background color using ngStyle working

here is my code:
page.html:

<div id="mydiv" [ngStyle]="{'background-color': divColor; 'width': divWidth}"></div>

page.ts:

  divColor: string;
  divWidth: any;

constructor(){
     this.divColor = 'rgb(34, 34, 34)';
    this.divWidth = 10;
}

Hi, @dipankar123

Yes, you can do it!

More info

thanks

thanks for rply,
i have tried this but nothing happened. width not working. i have gave my code, and tell me where i m wrong

@dipankar123

Yes because you can’t width in pixel or percentage give it in pixel or percentage like below code

 divColor: string;
  divWidth: any;

constructor(){
     this.divColor = 'rgb(34, 34, 34)';
    this.divWidth = '10px';
}

Thanks

it working, thank u so much for rply.
u r right i forgot to type px or %
thanks again

If solution works for you then please mark it as a solution