When I try to use the increment operator within ngoninit() to change a variable's value, I encounter the following error from the compiler:
error TS2356: An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type.
This is my code snippet inside ngoninit():
ngOnInit() {
if(!localStorage.getItem("tempuid")) {
localStorage.setItem("tempuid","0");
}
let uid = localStorage.getItem("tempuid");
uid++;
localStorage.setItem("tempuid",uid);
}
I'm looking for a solution to successfully increment the value of "uid" or any alternatives to achieve this. Thank you in advance.