2017-12-28 3 views
0

Ich habe ein reaktives Formular in Winkel 5, wo ich einige Daten bearbeiten. Um die Daten zu bearbeiten, ziehe ich natürlich zuerst die Daten aus dem DB und zeige sie in meiner reaktiven Form an.Angular 5 Reactive Forms - Probleme Einstellung Datum von DB

Die DB kehrt das Datum folgendes Format:

2017-07-13T23:00:00.000Z 

Mein HTML-Code ist:

<input class="uk-input" type="date" placeholder="Enter Issue Date" formControlName="IssueDate"> 

Mein Component-Code ist:

this.proposalForm.setValue({ 

     sector: this.proposal.sector, 
     client: this.proposal.client, 
     owner: this.proposal.owner, 
     IssueDate: this.proposal.IssueDate, 

    }); 

Alle Textfelder sind ausgefüllt, aber das Feld date bleibt leer. Was mache ich falsch?

Antwort

0

Der Eingang type="date" unterstützt nur das Format YYYY-MM-DD. können Sie tun this.proposal.IssueDate.substr(0,10) oder this.proposal.IssueDate.split('T')[0]

var somedate = "2017-07-13T23:00:00.000Z"; 
 

 
my_date.value = somedate.substr(0,10);
<input type="date" id="my_date"/>

Verwandte Themen