2016-02-14 68 views
-1

我有一個觀察到其中有這樣firstNamefirstNameText插入空隙 - 淘汰賽

當我展示它的價值,我怎麼能在大寫字母之前添加空間。

firstnameFirst NamefirstNameTextFirst Name Text

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

我需要做的是在HTML本身。

+0

[轉換camelCaseText駱駝案例文本]可能的複製(http://stackoverflow.com/questions/7225407/convert-camelcasetext-to-camel-case-text) – Jeroen

回答

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