Set width of <span> programmatically

#1

Is it possible to set the width of an html tag like <span> programmatically?

Fixed values of the width of <span> I can set e.g. with

<span style="display: inline-block; width: 150px;">

I want to set the width instead of 150px to another value dependent of the needed space for content.

#2

<span [style.width]=foo></span>
Change the value of ‘foo’ in your .ts file
https://angular.io/docs/ts/latest/guide/template-syntax.html#!#style-binding

#3

It works! Thank you very much for your fast response.