日期从 webapi 进入 angular 4
Date get in angular 4 from webapi
仅日期获取 Angular 4 来自网络Api
publish Date Get from webApi <br>
<PublishDate>2018-03-02T00:00:00</PublishDate><br>
打字稿Class:
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;
}
发布日期框
你能解释一下你到底想要什么吗,我给你我理解的爱的解决方案
也许这段代码能帮到你
<input type="date" class="form-control" max="{{todaysDate|date:'yyyy-MM-dd'}}" #myDate [value]="your model | date:'yyyy-MM-dd'"
(input)="your model=$event.target.value" />
仅日期获取 Angular 4 来自网络Api
publish Date Get from webApi <br>
<PublishDate>2018-03-02T00:00:00</PublishDate><br>
打字稿Class:
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;
}
发布日期框
你能解释一下你到底想要什么吗,我给你我理解的爱的解决方案
也许这段代码能帮到你
<input type="date" class="form-control" max="{{todaysDate|date:'yyyy-MM-dd'}}" #myDate [value]="your model | date:'yyyy-MM-dd'"
(input)="your model=$event.target.value" />