I am not sure why my foreach sections isn't working? The very first data-bind text: Id is working though.
Knockout:
import Knockout from 'knockout';
function ViewModel() {
var self = this;
self.Id = ko.observable();
self.Sections = ko.observableArray();
};
var viewModel = new ViewModel();
ko.applyBindings(viewModel);
$.getJSON("/api/projects/3455", function(data) {
console.log(data);
viewModel.Id(data.Id);
viewModel.Sections(data.Sections);
});
HTML:
<div data-bind="text: Id">
<div data-bind="foreach: Sections">
<div data-bind="text: Id"></div>
</div>
</div>
Returned JSON:
