phenomnomnominal / angular-2-local-storage

LocalStorageService for Angular 2 with the same API as angular-local-storage
MIT License
93 stars 49 forks source link

TypeError: Cannot read property 'notifyOptions' of null #62

Closed kesdeband closed 5 years ago

kesdeband commented 5 years ago

This error occurred after installing the latest version of angular-2-local-storage. Possibly a bug?

phenomnomnominal commented 5 years ago

Published a fix at 3.0.1

wanderlux commented 5 years ago

Still occurring at 3.0.2 after just installing.

If no configuration is provided (as it says it is optional) at function LocalStorageService(config) config takes null value and if (config === void 0) evaluates to false therefore config object is never initialized and line 65 var notifyOptions = config.notifyOptions, prefix = config.prefix, storageType = config.storageType; throws the error.

I have found a workaround by providing an empty config object:

LocalStorageModule.forRoot({ })

phenomnomnominal commented 5 years ago

Just to confirm is this that LocalStorageModule.forRoot(null) throws the error? Or LocalStorageModule.forRoot()?

tylerforsythe commented 5 years ago

LocalStorageModule.forRoot() works. LocalStorageModule.forRoot({}) works. LocalStorageModule.forRoot(null) throws it. Leaving this line out of imports entirely: throws it.

Hope this helps! Thanks!