Angular4.0 format () method error report

A date conversion method that displays both mouse over format and subDays.
always prompts for one more parameter. What"s wrong?

export interface Age {
  age: number;
  unit: AgeUnit;
}
    const age$ = Observable
      .combineLatest(ageNum$, ageUnit$, (_n, _u) => {
        return this.toDate({age: _n, unit: _u});
    })



format:

subDays:

Apr.09,2021

you don't give a prototype of the format function, so you can only guess that there is a time formatted function library called format.js
that provides a similar method, but it defines format on the prototype chain, so it is called like this date.format ('mm-dd-YYYY')

.

I don't know what the value returned by your subxxx series function is. If it is directly a Date Object
, your calling method should be

.
 return subYears(now, age.age).format(dateFormat);
//Date

look at the screenshot should be format passed an extra parameter, check the Angular document, it should not be the method of Angular itself.

if you want the effect of date conversion, you can consider pipe

or try this formatDate

Menu