Skip to content Skip to sidebar Skip to footer

Trying To Map Array From Json To Knockout Using Mappings

Hi I have a JSON array like so [{ 'id': '537901a53513fa3374bec718', 'images': [], 'itemImage': 'img/3.jpg', 'createdDate': '5/18/2014 6:53:25 PM', 'location':

Solution 1:

All you need to do is the following:

var viewModel = ko.mapping.fromJS(data);
ko.applyBindings(viewModel);

You loop them as follows:

<tableclass="table table-striped"><tbodydata-bind="foreach: $data"><tr><tddata-bind="text: id"></td></tr></tbody></table>

See example here:

http://jsfiddle.net/wr5W7/5/

Post a Comment for "Trying To Map Array From Json To Knockout Using Mappings"