仅从WebApi获取Angular 4中的日期
publish Date Get from webApi <br>
<PublishDate>2018-03-02T00:00:00</PublishDate><br>
typescript类:
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;
}
发布日期框