I have a data table which display data from external API, I want the number of items /element on the table page should be saved in local storage
Here is what I have tried so far:
ngOnInit() {
this.moviesService.getPopularTVShows().subscribe(res => {
this.dataSource = new MatTableDataSource(res.results);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
localStorage.setItem(this.dataSource, this.dataSource.length);
console.log(localStorage.length);
});
}
When I run my app, the console displays undefined
What is wrong with my code? any help or suggestion is welcomed, newbie trying new stuff.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…