Open JanOschii opened 4 years ago
I needed a minute to understand the example code and I didn't think that was necessary. Therefore here is an alternative version.
import { Inject, Injectable } from '@angular/core'; import { LOCAL_STORAGE, StorageService } from 'ngx-webstorage-service'; @Injectable() export class VisitCounterService { constructor( @Inject(LOCAL_STORAGE) private storage: StorageService ) {} public countVisit(): number { const count: number = this.storage.get('visits') || 0 this.storage.set('visits', count + 1) return count } }
I needed a minute to understand the example code and I didn't think that was necessary. Therefore here is an alternative version.