knockout.js - How do I access an object by index in a knockout observablearray? -


i have observable array:

var myobservablearray = ko.observablearray([     { name: "car", price: "9999" },     { name: "shoes", price: "20" },     { name: "paper", price: "1" } ]); 

i'm trying access price of first item in array.

<div data-bind="text: myobservablearray()[0]"></div> 

displays:

[object object] 

i've tried:

<div data-bind="text: myobservablearray()[0].price"></div> 

but returns null.

what's correct syntax doing this?

edit: fixed copy , paste error pointed out below.

other using wrong property name, developerexampledata instead of myobservablearray, code fine.

here working fiddle


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -