I’ll keep it short. My view model looks like this:
var ViewModel = {
Cameras: ko.observableArray(),
Current: ko.observableArray()
};
and I want to do something like this:
<!-- ko foreach: Cameras -->
<div data-role="collapsible">
<h3 data-bind="text: CameraName"></h3>
<!-- ko foreach: Current -->
<img data-bind="attr: { src: URL }" />
<!-- /ko -->
</div>
<!-- /ko -->
CameraName property is from Cameras array and URL property is from Current array, but when I do this I get “Current is not defined”. I’ve looked into nested foreach but there must be something I’m not understanding properly.
Currenthas to be a property of the item inCameras.Like so…
You could try Knockout 2.1’s
$parent.