this is my class logger and the error here will be shown on setTimeout function-
export class logger{
WriteLogger() {
let dateTime,dd,mm,yyyy,h,m,s,m1,s1;
console.log("logger class is called");
//console.log(new Date().getCurrent);
dateTime = new Date();
dd = dateTime.getDate();
mm = dateTime.getMonth() + 1;
yyyy = dateTime.getFullYear();
h = dateTime.getHours();
m = dateTime.getMinutes();
s = dateTime.getSeconds();
m = this.checkTime(m);
s = this.checkTime(s);
setTimeout(( => {
console.log(dd + "/" + mm + "/" + yyyy + " The Current Time is " + h +":" + m + ":" +s);
}),500);
}
checkTime(i){
if(i<10){
i = "0" + i;
}
}
}
But I am getting this error:
ERROR in src/app/logger.ts(18,16): error TS1005: '(' expected
答案 0 :(得分:0)
setTimeout
should be self invoking
Change setTimeout
setTimeout(( => {
console.log(dd + "/" + mm + "/" + yyyy + " The Current Time is " + h +":" + m + ":" +s);
}),500);
To
setTimeout(() => {
console.log(dd + "/" + mm + "/" + yyyy + " The Current Time is " + h +":" + m + ":" +s);
}, 500) ()