Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 空数据转换为{1/1/0001 12:00:00 AM}_Json_Angularjs_Asp.net Mvc - Fatal编程技术网

Json 空数据转换为{1/1/0001 12:00:00 AM}

Json 空数据转换为{1/1/0001 12:00:00 AM},json,angularjs,asp.net-mvc,Json,Angularjs,Asp.net Mvc,我有带有id和date的型号。然后我将其设置为angular.toJson,并发送到服务器。问题在于:如果my date为空,则服务器上的模型日期字段显示为{1/1/0001 12:00:00 AM},但不为空。如何解决这个问题?我需要null 这是angularjs控制器,我的函数在这里调用 $scope.filterModel = function (filter) { postService.getFilteredByUserId($scope.bindModel, angular

我有带有
id
date
的型号。然后我将其设置为
angular.toJson
,并发送到服务器。问题在于:如果my date为空,则服务器上的模型日期字段显示为{1/1/0001 12:00:00 AM},但不为空。如何解决这个问题?我需要
null

这是angularjs控制器,我的函数在这里调用

$scope.filterModel = function (filter) {
    postService.getFilteredByUserId($scope.bindModel, angular.toJson(filter));
};
这是我的服务器函数,它得到了这个模型

[HttpPost]
public IEnumerable<TimesheetModel> FilterModel(TimesheetFilterModel filter)
{
    return TimesheetService.FilterTimesheetListByFilter(filter);
}
默认情况下,DateTime不可为空。您需要使它们可以为null,并在构造函数中将它们设置为null


默认情况下,DateTime不可为空。您需要将它们设置为null,并在构造函数中将它们设置为null。

您可以将datetime属性设置为null,以便在获取null值时处理null

DateTime在c#中是一种值类型,因此无法直接在其中分配null值

DateTime? nullableDate;
dateSample.Value = null;

在您的情况下,它将默认为
DateTime.MinValue

您可以将DateTime属性设置为null,以便在获取null值时处理null

DateTime在c#中是一种值类型,因此无法直接在其中分配null值

DateTime? nullableDate;
dateSample.Value = null;

在您的情况下,它将默认为
DateTime.MinValue

您应该使用
nullableYeah,当然。我的小姐。。。谢谢你应该使用
nullable是的,当然。我的小姐。。。谢谢您不需要在构造函数中设置
null
(默认值为
null
)您不需要在构造函数中设置
null
(默认值为
null
)您不需要在构造函数中设置null(默认值为null)您不需要在构造函数中设置null(默认值为null)
DateTime? nullableDate;
dateSample.Value = null;