How to bind a property to style.width in pixels?

Works fine for me

Plunker example

@Component({
  selector: 'my-app',
  styles: [`div { border: 3px solid red; }`]
  template: `
    <div>
      <h2>Hello {{name}}</h2>
      <div [style.width.px]="width">some texts </div>

    </div>
  `,
})
export class App {
  name:string;
  width: number = 250;
  constructor() {
    this.name="Angular2"
  }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)