1

I am using knockout data binding to render an editor for a string => string dictionary. However, I'm running into trouble when dictionary keys contain special characters such as colon. Is there a way to "escape" a property name or special character such that knockout will bind properly? For example, the following does not bind properly:

<p data-bind="text: foo::bar" />

I am using version 2.1.0 of knockout

ChaseMedallion
  • 20,860
  • 17
  • 88
  • 152

1 Answers1

6

You need to use $data to access the currently bound object and from there the array indexer syntax to access any of its properties which are containing special characters:

<p data-bind="text: $data['foo::bar']" />

Demo JSFiddle.

Community
  • 1
  • 1
nemesv
  • 138,284
  • 16
  • 416
  • 359