-1
我有一個觀察到其中有這樣firstName
或firstNameText
插入空隙 - 淘汰賽
當我展示它的價值,我怎麼能在大寫字母之前添加空間。
firstname
將First Name
和firstNameText
將First Name Text
<span data-bind="text: name"></span>
我需要做的是在HTML本身。
我有一個觀察到其中有這樣firstName
或firstNameText
插入空隙 - 淘汰賽
當我展示它的價值,我怎麼能在大寫字母之前添加空間。
firstname
將First Name
和firstNameText
將First Name Text
<span data-bind="text: name"></span>
我需要做的是在HTML本身。
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
[轉換camelCaseText駱駝案例文本]可能的複製(http://stackoverflow.com/questions/7225407/convert-camelcasetext-to-camel-case-text) – Jeroen