Your code is correct. Just check styles of your div using inspect element.
Press F12 or hit ctrl + shift + i to open Inspect. Go to Elements Tab and find you div and check it's CSS properties, width is applied.
for Example:
element.style { background-color: pink; width: 150px; }
Otherwise add background color to your div tag so It will easily visible to you.
.html file (template)
<div [style.width.px]="width" style="background-color:pink"> some text </div>
Or
<div [ngStyle]="{'width.px': width}" style="background-color:pink"> some text </div>
.ts file (component)
export class MyComponent { width: number = 150; }