public arraySuccess = [];
ngOnInit(): void {
this.arraySuccess = JSON.parse(localStorage.getItem('success'));
}
openDialog(String) {
this.dialog.open(RecommendationsDialog);
if(this.arraySuccess != null &&
this.arraySuccess.includes(String)) {
return
} else if (this.arraySuccess != null) {
this.arraySuccess.push(String);
}
localStorage.setItem('success', JSON.stringify(this.arraySuccess));
console.log(this.arraySuccess);
}
I have a total of 3 articles. Whenever they are opened, I want to store their names in the localstorage
. When the user revisits the page, I want to display a read checkbox next to the article's name (checking if the name is in the localstorage
array).
However, I am facing an issue where I see null
in the console.
Can anyone help me find my mistake?