Angularjs 从“转换”;yyyy MM ddTHH:MM:ss“;至;yyyy-MM-dd“;安格拉斯

Angularjs 从“转换”;yyyy MM ddTHH:MM:ss“;至;yyyy-MM-dd“;安格拉斯,angularjs,Angularjs,我遇到的问题是,由于我使用的是ng模型,因此我无法执行类似{{myDate | date:“yyyy-MM-dd”}的操作 <div class="col-lg-7"> <input type="datetime-local" class="form-control" ng-model="currentAccount.InceptionDate" ng-init="currentAccount.InceptionDate = parseDate(currentAccoun

我遇到的问题是,由于我使用的是
ng模型
,因此我无法执行类似
{{myDate | date:“yyyy-MM-dd”}
的操作

<div class="col-lg-7">
   <input type="datetime-local" class="form-control" ng-model="currentAccount.InceptionDate" ng-init="currentAccount.InceptionDate = parseDate(currentAccount.InceptionDate)">
</div>
我在
return
语句中放了一个断点。它说,
date
未定义。 另一件事是,
InceptionDate
在我的
Account.cs
类中定义时,它的类型是
DateTime
,而不是
string
。我不确定这是否是真正的原因

如果我的HTML是这样的,它工作正常,但是日期不是我想要的格式(它显示的是
2015-08-10T00:00:00
):


如果
currentAccount.InceptionDate
既是一个
日期
对象又是一个范围变量,那么您应该能够执行以下操作:

{{currentAccount.InceptionDate | date: "yyyy-MM-dd"}}
例如:


您是否使用过moment.js。您可以使用$window获取矩对象并以任何方式解析它www.momentjs.com/您能提供一个提琴吗?您所写的内容目前没有太多上下文。currentAccount是,但InceptionDate不是。currentAccount是Account.cs类的对象。我不确定我是否理解。你能更新小提琴以适应你的场景吗?哦,对不起,我以为它也会更新你的小提琴。首先,你在
服务上没有右括号。其次,我没有访问您的
accountResource.detail.query
API的权限。您需要为
currentAccount
填写虚拟数据。让它模拟真实的东西。第三,
$scope.currentAccount=accountFactory.currentAccount将始终返回空对象。
<div class="col-lg-7">
   <input type="text" class="form-control" ng-model="currentAccount.InceptionDate" >
</div>
{{currentAccount.InceptionDate | date: "yyyy-MM-dd"}}