2015-11-05 119 views
1

我使用角度日期选择器。但它给出了以下错误。请告诉我如何解决它。提前致谢。错误:ngModel:datefmt模型不是日期对象

HTML

<input type="date" uib-datepicker-popup ng-model="vm.property.deedDate" 
    is-open="status.opened" datepicker-options="vm.dateOptions" 
date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" /> 

JS

vm.property = {}; 

vm.init = function() { 
       propertyService.getPropertyForEdit({ 
        id: propertyId 
       }).success(function (result) { 
        vm.property = result.property; 
        vm.property.deedDate = moment(vm.property.deedDate); 
       }); 
      }; 

      vm.init(); 

从网页API返回:

enter image description here

网络API DTO对象:

public class PropertyEditDto : IOutputDto 
    { 
     public int Id { get; set; } 
     public DateTime DeedDate { get; set; } 
    } 

它使下面提到的控制台错误:

enter image description here

+0

PLZ检查这个【答案】(http://stackoverflow.com/a/30537983/3033318) – macrog

+0

@macrog我已经这样设置'vm.property.deedDate =时刻();'。但它仍然提供了相同错误。为什么? – Sampath

+0

我不知道,创建一个plunker,所以我可以帮你 – macrog

回答

5

请试试这个:

vm.property.deedDate = new Date(vm.property.deedDate); 

它应该工作!

+0

非常感谢:) – Sampath