0
我正在嘗試爲asp.net mvc淘汰js。我有以下的HelloWorld示例:綁定不起作用
@using PerpetuumSoft.Knockout
helloworld thing
@model koHelloworld.Models.HelloWorldModel
@{
var ko = Html.CreateKnockoutContext();
}
<p>First name: @ko.Html.TextBox(m => m.FirstName)</p>
<p>Last name: @ko.Html.TextBox(m => m.LastName)</p>
<h2>Hello, @ko.Html.Span(m => m.FullName)!</h2>
@ko.Apply(Model)
模型
namespace koHelloworld.Models
{
public class HelloWorldModel
{
public string FirstName { get; set; }
public string LastName { get; set; }
[Computed]
public string FullName
{
get { return FirstName + " " + LastName; }
}
}
}
控制器
public class HelloWorldController : BaseController
{
public ActionResult Index()
{
InitializeViewBag("Hello world");
return View(new HelloWorldModel
{
FirstName = "Steve",
LastName = "Sanderson"
});
}
}
但是綁定不起作用?什麼可能是錯誤的?
您是否在視圖或_layout.chstml中包含了所有必需的JavaScript文件? – nemesv