I'm working on a simple web page using knockout. Consider I have the following ViewModel function
self.sample_data = ko.observableArray([
{
1:[
{ title1:"abc", title2:"def"},
{ title1:"abc", title2:"def"}
],
2:[
{ title1:"ghi", title2:"jkl"},
]
}
]);
Am able to bind the specific json value with key value as '1' to the view layer as follows.
<h1 data-bind="text:sample_data[0].1[0].title1"></h1>
Consider I have two buttons 'previous' and 'next'. On clicking the button 'next' I should bind the data associated with key value as '2' in the JSON to the same h1
tag. How can we acheive that?