You should define a key name while storing data to local storage which should be a string and value should be a string
localStorage.setItem('dataSource', this.dataSource.length);
and to print, you should use getItem
console.log(localStorage.getItem('dataSource'));
More Related Contents:
- localStorage is not defined (Angular Universal)
- How do I create a singleton service in Angular 2?
- Call child component method from parent class – Angular
- How can I unit test a component that uses the Router in Angular?
- Angular2, what is the correct way to disable an anchor element?
- document.getElementById replacement in angular4 / typescript?
- Angular 4/5/6 Global Variables
- Property ‘controls’ does not exist on type ‘AbstractControl’ Angular 4 [duplicate]
- Angular 2/4 component with dynamic template or templateUrl
- Angular 12 source map is missing in browser
- Use nav.push with side menu in ionic 2
- Angular 5 – Copy to clipboard
- Pass config data using forRoot
- Highlight the search text – angular 2
- Angular 4 checkbox change value
- Debug & Run Angular2 Typescript with Visual Studio Code?
- Angular @ViewChild() error: Expected 2 arguments, but got 1
- Best way to import Observable from rxjs
- Ionic2/Angular2 – Read a custom config file
- Do I have to unsubscribe from ActivatedRoute (e.g. params) observables?
- rxjs/Subject.d.ts error : Class ‘Subject’ incorrectly extends base class ‘Observable’
- FormBuilder group is deprecated
- TypeScript-‘s Angular Framework Error – “There is no directive with exportAs set to ngForm”
- How to return observable from subscribe
- How to mock Angular 4.3 httpClient an error response in testing
- Angular 2 creating reactive forms with nested components
- Limit input field to two decimal places – Angular 5
- Angular 6 – how to mock router.events url response in unit test
- How to create and download text/Json File with dynamic content using angular 2+
- Angular4 Load external html page in a div