I am trying to pass parameter to URL. For which I am using Angular HttpParams. How do I set date param only if date is not null or undefined?
Code:
let params = new HttpParams()
.set('Id', Id)
.set('name', name)
if (startDate !== null) {
params.set('startDate', startDate.toDateString());
}
if (endDate !== null) {
params.set('endDate', endDate.toDateString());
}