I am using Angular 7 for my Web app and have the following code in html:
<div class="form-group col-md-6">
<label for="myDate">My Date</label>
<div class="input-group">
<input
class="form-control"
placeholder="yyyy/mm/dd"
id="myDate"
name="myDate"
[ngModel]="project.myDate | date: 'yyyy/MM/dd'"
ngbDatepicker #d="ngbDatepicker"
tabindex="9">
<div class="input-group-append">
<button class="btn btn-outline-secondary calendar" (click)="d.toggle()" type="button"></button>
</div>
</div>
</div>
When calling a Web API I got a JSON object like this:
{
"id": 11,
"description": "This is a test description",
"budget": 1000,
"myDate": "2020/02/11",
...
}
This is the component code:
export class ProjectEditComponent implements OnInit {
project: Project;
errorMessage: string;
constructor(private myprojectService: ProjectService) { }
ngOnInit() {
this.myprojectService.getDataById(this.dataId).subscribe(
data => (this.project = data, console.log(JSON.stringify(data))),
error => this.errorMessage = error as any,
);
console.log(this.errorMessage);
}
}
All the properties are bind properly except myDate property.
I have doing some research and trying different propose solutions , but none one seems to work so far.
Does any one of you face something similar?