How to enable data binding in KnockoutJS using the ASP.NET MVC 3 “Razor” View Engine?

后端 未结 2 888
猫巷女王i
猫巷女王i 2020-12-24 09:43

I\'m trying to implement this Knockout example using ASP MVC 3\'s \"Razor\" view engine.

The first topic covers simple data binding of a C# array using the standard

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-24 10:11

    The easiest way in MVC3 is to do:

    var initialData = @Html.Raw(Json.Encode(Model));
    

提交回复
热议问题