Is it possible to use data-bind: foreach
for more than one array?
For example:
//do s
I don't think there is any official way of doing so, but a workaround would be, to use $index
along with foreach
on the longer array. Something like this:
var model = function() {
var self = this;
self.arr1 = ko.observableArray([1,2,3, 5, 6]);
self.arr2 = ko.observableArray([1,2,3,4]);
}
ko.applyBindings(new model());
span {
font-weight: bold;
}
Index:
,
Array 1:
,
Array 2:
,
Longer array:
,
Shorter array: