At the top of my partial view I have "@model PeopleDTO", which is a List<PeopleDTO> object (in C#) I would like to have Knockout display the list of names as a link, so I can click on each name. I'm fairly new to javascript and knockout, but not new to C#. All the examples in the Knockout site seem to deal with data arrays embedded in the javascript. Probably not real world, at least not mine. :-) so I'm needing to transition from accessing in-line arrays to database models.
I tried the following code, but this didn't work:
var personList = '@(Model)';
function PersonViewModel() {
var self = this;
self.People = ko.observable(personList);
self.Name = ko.computed(function() {
return self.firstName() + " " + this.lastName();
});
}
ko.applyBindings(new PersonViewModel);
Any help would be appreciated.