I am new to Angular 6. With the following code:
export class DateComponent implements OnInit {
currentDate: string = new Date().toDateString;
constructor() { }
ngOnInit() {
}
}
I am getting the following error, but I do not know what may be causing it.
error TS2322: Type '() => string' is not assignable to type 'string'.
You should invoke the function, not assign the function object. Adding () at the end should fix it
currentDate: string = new Date().toDateString();
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