控制器代碼:MVC 4模型KnockoutJS綁定
public ActionResult Index()
{
PersonRepository repo = new PersonRepository();
PersonListModel lstPersons = new PersonListModel();
lstPersons.Persons = repo.GetAllPerson();
return View(lstPersons);
}
實際的JavaScript代碼:
<script type="text/javascript">
var personListData = @Html.Raw(Json.Encode(Model.Persons));
var viewModel = {
personsModel : ko.observableArray(personListData)
}
ko.applyBindings(viewModel)
<script/>
結果,而Debugigng:
var personListData = [
{"PersonId":324783035204000026,"FirstName":"Gibbbs","BirthDate":"\/Date(1347647400000)\/"},{"PersonId":324126155204000001,"FirstName":"Russel","BirthDate":"\/Date(1347561000000)\/"}];
*問題:
當模型數據得到bindinng它會告訴我的人ID爲:324783035204000026但是當綁定過程得到完成它做變動成PERSONID爲:324783035204000000及324126155204000001至324126155204000000
日期數據也無法正常結合。
那麼它背後的主要原因是什麼?
如果您對此有任何想法,請幫助我。