As you have it, you can bind to it like this
<div data-bind="foreach: $root">
<span data-bind="text: Name"></span>
... etc ...
</div>
BUT, I would do it like this
var myViewModel = {};
$(function() {
var jsonModel = '@Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(this.Model, new Newtonsoft.Json.Converters.IsoDateTimeConverter()))';
myViewModel.customers = ko.mapping.fromJS(jsonModel);
ko.applyBindings(myViewModel);
});
Then you can put in your markup
<div data-bind="foreach: customers">
<span data-bind="text: Name"></span>
... etc ...
</div>
Because now you can add more properties to your viewmodel, which you surely will need.
UPDATE: Here's a working jsfiddle. Remember the call is fromJS
, not fromJSON
.