【发布时间】:2018-05-09 20:33:28
【问题描述】:
仅日期从 WebApi 获取 Angular 4
publish Date Get from webApi <br>
<PublishDate>2018-03-02T00:00:00</PublishDate><br>
打字稿类:
export class IResource {
ResourceId: number;
ResourceTitle: string;
Description: string;
PublishDate?: Date;
ImgUrl: string;
}
服务:
GetResourceById(resourceId) {
this.appServiceManager.libGet("Resource/" + resourceId).
subscribe((response: any) => {
this.resource = response;
}
}, (error: any) => {
alert(error);
});
}
HTML 文件:
<div class="col-md-4 noPadding">Publish Date</div>
<div class="col-md-8 noPadding">
<p-calendar name="PublishDate" [(ngModel)]="resource.PublishDate"
dateFormat="mm/dd/yy" [showIcon]="true"></p-calendar>
</div>
获取发布日期的 API 服务
public ResourceDTO Find(int id)
{
//get resource get by id
Resource dbresource = _db.Resources.Where(m => m.ResourceId == id).FirstOrDefault();
ResourceDTO resourcesDTO = Mapper.Map<ResourceDTO>(dbresource);[enter image description here][1]
return resourcesDTO;
}
发布日期框
【问题讨论】:
-
你知道有角的管道吗?
-
我的问题通过日期管道解决了
标签: date sql-server-2012 asp.net-web-api2 angular4-forms