Knockout text anchor when name contains period

I got data from the Dailymotion API.

  "created_time": 1391086059,
  "message": "20 minutes rime avec fils de.",
  "owner.username": "Mejicano777"

How to use data-bindfor the 'text' property on 'owner.username'?

I tried:

<strong data-bind="text: owner.username"></strong>

But that will not work.

Thanks.

+4
source share
1 answer

You need to use the $data binding context property and use the array index index syntax to access your property with a dot in its name:

<strong data-bind="text: $data['owner.username']"></strong>

JSFiddle demo .

+4
source

Source: https://habr.com/ru/post/1524595/


All Articles