-1

I have an observable which has the value like this firstName or firstNameText

When I am displaying it, how can I add space before the capital letters.

firstname will be First Name and firstNameText will be First Name Text

<span data-bind="text: name"></span>

I need to do it in the HTML itself.

user2281858
  • 1,957
  • 10
  • 41
  • 82
  • Possible duplicate of [Convert camelCaseText to Camel Case Text](http://stackoverflow.com/questions/7225407/convert-camelcasetext-to-camel-case-text) – Jeroen Feb 14 '16 at 17:45

1 Answers1

0
text: name()
.replace(/([A-Z])/g, ' $1')
.replace(/^./, function(str){ return str.toUpperCase(); })
// you could add plain javascript expressions in the text binding but you have to call the observable to get the value
yoel neuman
  • 133
  • 7