Answer the question
In order to leave comments, you need to log in
How to get property value in template from associative array in knockout.js ?
Here is such a design:
Item = ko.observableArray();
//...
oneItem().item = item;
oneItem().category = category;
oneItem = [
category:
{
checked: 1,
name: "Вода",
title: "Выбрать воду",
type: "water",
},
item:
{
color: "Прозрачная",
id: 2,
name: "Просто вода",
price: 100,
src: "src/water.jpg",
}
]
<img class="popup-img" data-bind="attr: { src: oneItem().item.src }"/>
<strong data-bind="text: oneItem().item.color"></strong>
console.log(oneItem().item.src);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question