import angular , { IWindowService } from 'angular' ; export class DataStorageService { public static $inject = [ '$window' ] ; public constructor ( private readonly $window ) { } public saveData ( key , data ) { this . $window . localStorage . setItem ( key , angular . toJson ( data ) ) ; } public loadData ( key , def ) { const item = this . $window . localStorage . getItem ( key ) ; return item === null ? def : angular . fromJson ( item ) ; } }