How can i convert '[object Object]'(datepicker) to date format
<input type="text"
       id="date"
       class="form-control"
       formControlName="date"
       name="date"
       [(ngModel)]="date"
       ngbDatepicker
       #incorporatedDatePicker="ngbDatepicker"
       (click)="incorporatedDatePicker.toggle()"
       readonly>
when i display
    {{meeting.date | date }} 
i have error: invalidPipeArgument Error '[object Object]' for pipe 'DatePipe'
For those still looking for an answer to this, you have to use the NgbDateAdapter provider like shown in the docs:
import { NgbModule, NgbDateAdapter, NgbDateNativeAdapter } from '@ng-bootstrap/ng-bootstrap';
@NgModule({
  imports: [
    NgbModule.forRoot(),
    ...
  ],
  providers: [{
    provide: NgbDateAdapter,
    useClass: NgbDateNativeAdapter
  }]
})
export class AppModule { }
Then when using [(ngModel)]="from" on the input it will automatically use the model as a Date
Based on your comment, what you are trying to feed to the DatePipe is...
{ "day": 18, "month": 8, "year": 2017 }
Angular cannot read an object like that and understand that is a date. You need to transform it before to some format that Angular can understand. Formats that are accepted is mentioned in docs:
date_expression | date[:format]
expressionis a date object or a number (milliseconds since UTC epoch) or an ISO string (https://www.w3.org/TR/NOTE-datetime).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With