MALIK MAHSAM KHAN
MALIK MAHSAM KHAN

Reputation: 35

Date get in angular 4 from webapi

Only date Get in Angular 4 From WebApi

publish Date Get from webApi <br>
<PublishDate>2018-03-02T00:00:00</PublishDate><br>

typescript Class:

export class IResource {
    ResourceId: number;
    ResourceTitle: string;
    Description: string;
    PublishDate?: Date;
    ImgUrl: string;  
}

Service:

GetResourceById(resourceId) {
    this.appServiceManager.libGet("Resource/" + resourceId).
        subscribe((response: any) => {
            this.resource = response;            
           }

        }, (error: any) => {
            alert(error);
        });
}

Html File:

 <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 Service to get publish Date

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;

}

Publish date box

a

Upvotes: 0

Views: 53

Answers (1)

bhaumik shah
bhaumik shah

Reputation: 206

can you please explain what you exactly want and I give you belove solution as my understanding

maybe this code will help you

 <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" />

Upvotes: 1

Related Questions