javascript里面的话x=>x.Title相当于
function(x){return x.Title}你可以试试:
let y=x=>xconsole.log(y(1))//1
其实就相当于:
let y=function(x){return x
}
console.log(y(1))//1
你那个x.Title应该是传入的x值为一个对象。
Try this@Html.TextBoxFor(model =>model.CreationDate,
new { @type = "date", @Value = Model.CreationDate.ToString("yyyy-MM-dd") })
You have to handle null when setting the value.
OR
If you can change the Model you can try this
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public DateTime CreationDate{ getset}
and in your view you can use EditorFor helper.
@Html.EditorFor(model =>model.CreationDate, new { @type = "date" })