Problems using the Razor model when creating my knockout ViewModel
- by Emil Kantis
I'm having problems with using the Model in a javascript call when setting up my knockout VM..
@model List<AdminGui.Models.Domain>
<script src="http://ajax.aspnetcdn.com/ajax/knockout/knockout-2.2.1.js" type="text/javascript"></script>
<script type="text/javascript">
function ViewModel() {
var self = this;
self.domains = ko.observableArray(
ko.utils.arrayMap(@Model, function(item) {
return new Domain(item.guid, item.description, item.namespaces);
}));
}
I get a syntax error on @Model in the ko.utils.arrayMap call. I suspect it might be my Razor-fu that is lacking... :)