im trying to affect a set Attribute from class.ts with a variable in my component.ts ( angular ) like this :
this.UserPaiemet.setDate(this.DateN)
The IDE shows me this errors :
Argument of type 'string | null' is not assignable to parameter of type 'String'.
Type 'null' is not assignable to type 'String'.
131 this.UserPaiemet.setDate(this.DateN)
i don't know how can i fix it .
My class:
export class UserPaiemet
{
private id!:Number;
private date!:String;
private nbrmois!:Number;
}
ANd my component Method
date = new Date()
DateN = this.datePipe.transform(this.date, "yyyy-MM-dd")
UserPaiemet= new UserPaiemet()
updateUserPai()
{
this.UserPaiemet.setDate(this.DateN)
}
this.dataPipecode? TypeScript is complaining that that might returnnull, and then you can't pass that intosetDate.nullvalue coming out ofdatePipe.transform. WIth aniffor instance