Problems using the Razor model when creating my knockout ViewModel
Posted
by
Emil Kantis
on Stack Overflow
See other posts from Stack Overflow
or by Emil Kantis
Published on 2013-07-02T04:57:35Z
Indexed on
2013/07/02
5:05 UTC
Read the original article
Hit count: 200
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... :)
© Stack Overflow or respective owner