Coder Social home page Coder Social logo

angular-2-local-storage's People

Contributors

abriand-solicis avatar dependabot[bot] avatar dhjgodin avatar elwynelwyn avatar jaredtbates avatar jvanderbiest avatar mattlewis92 avatar phenomnomnominal avatar srudenko avatar sunshineo avatar tis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-2-local-storage's Issues

Unhandled Promise rejection: (SystemJS) XHR error

zone.js:484 Unhandled Promise rejection: (SystemJS) XHR error (404 Not Found) loading http://localhost:4200/vendor/angular-2-local-storage/index.js
When ng build is done the dist/vendor/angular-2-local-storage indside not have index.js file.
I am used your document. my system-config.ts file is
const map: any = {
'angular-2-local-storage': 'vendor/angular-2-local-storage',
};
const packages: any = {
'angular-2-local-storage': { main: 'index.js', defaultExtension: 'js' },
}
const barrels: string[] = [
// Thirdparty barrels.
'rxjs',
'angular-2-local-storage',
]

Please help.

[3.0.0] Error when run the project after build

Hi,

I update to 3.0.0 and the project runs perfectly to serve development.

But when I generated the build, the project don't run and I get the follows error on console:

main.42b2efa0809ff1ad1245.js:1 TypeError: Cannot read property '__source' of undefined
    at t.get (vendor.3ff8dc4fe5013ffbc0c4.js:1)
    at lg (vendor.3ff8dc4fe5013ffbc0c4.js:1)
    at t.get (vendor.3ff8dc4fe5013ffbc0c4.js:1)
    at De (vendor.3ff8dc4fe5013ffbc0c4.js:1)
    at Pe (vendor.3ff8dc4fe5013ffbc0c4.js:1)
    at Re (vendor.3ff8dc4fe5013ffbc0c4.js:1)
    at vendor.3ff8dc4fe5013ffbc0c4.js:1
    at vendor.3ff8dc4fe5013ffbc0c4.js:1
    at hg (vendor.3ff8dc4fe5013ffbc0c4.js:1)
    at lg (vendor.3ff8dc4fe5013ffbc0c4.js:1)

For now I needed to install the 2.0.0 again.

I use Angular 7.2.0.

Thanks!

get() method doesn't return string values which are not enclosed in quotes (")

3rd party libraries may access localStorage through window object which saves strings (e.g. authentication tokens by angular2-jwt) without quotes, e.g. (abcd...)

  • get() method parses stored values as JSON and requires all strings to be enclosed in quotes ("abcd...") and returns null otherwise.

as the result - there is no way to access saved data.

Creating a unit test that is using LocalStorageService

I am having an issue creating/running a unit test using angular-2-local-storage. I believe I have the test setup correctly, but getting this error. Not sure what to do next.

Error: No provider for LOCAL_STORAGE_SERVICE_CONFIG!

Setting up the test:
import { LocalStorageModule, LocalStorageService } from 'angular-2-local-storage';

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
LocalStorageModule.withConfig({
prefix: 'bpf',
// storageType: 'localStorage'
storageType: 'sessionStorage'
})
],
declarations: [
DisabilityQuoteComponent
],
providers: [LocalStorageService,
{ provide: WorkInProgressService, useValue: MockWorkInProgressService
}
]
})
.compileComponents();
}));

ng test error Error: StaticInjectorError(DynamicTestModule)[AuthenticationService -> LocalStorageService]

I'm getting this error when running ng test

        Error: StaticInjectorError(DynamicTestModule)[AuthenticationService -> LocalStorageService]:
        error properties: Object({ ngTempTokenPath: null, ngTokenPath: [ 'AuthenticationService', Function ] })
            at <Jasmine>
            at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get node_modules/@angular/core/fesm5/core.js:979:1)
            at resolveToken node_modules/@angular/core/fesm5/core.js:1232:1)
            at tryResolveToken node_modules/@angular/core/fesm5/core.js:1182:1)
            at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get node_modules/@angular/core/fesm5/core.js:1077:1)
            at resolveToken node_modules/@angular/core/fesm5/core.js:1232:1)
            at tryResolveToken node_modules/@angular/core/fesm5/core.js:1182:1)
            at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get node_modules/@angular/core/fesm5/core.js:1077:1)
            at resolveNgModuleDep node_modules/@angular/core/fesm5/core.js:9238:1)
            at _createClass node_modules/@angular/core/fesm5/core.js:9277:1)

Cannot find `Provider` and `provide`

import { Component } from '@angular/core';
import { Platform, ionicBootstrap } from 'ionic-angular';
import { StatusBar } from 'ionic-native';
import { LocalStorageService, LOCAL_STORAGE_SERVICE_CONFIG } from 'angular-2-local-storage';

// Create config options (see ILocalStorageServiceConfigOptions) for deets:
let localStorageServiceConfig = {
    prefix: 'my-app',
    storageType: 'sessionStorage'
};
// Provide the config to the service:
const LOCAL_STORAGE_CONFIG_PROVIDER: Provider = provide(LOCAL_STORAGE_SERVICE_CONFIG, {
    useValue: localStorageServiceConfig
});

// Use the provider:
ionicBootstrap(MyApp, [LocalStorageService, LOCAL_STORAGE_CONFIG_PROVIDER]);

TypeScript error: app/app.ts(29,38): Error TS2304: Cannot find name 'Provider'.
TypeScript error: app/app.ts(29,49): Error TS2304: Cannot find name 'provide'.

Angular 10 deprecated the use of ModuleWithProviders type without a generic.

image

Facing the following error while deploying as Angular 10 has deprecated the use of ModuleWithProviders type without a generic and the code in dist folder remains unchanged in the deployment causing the build to fail.

2021-01-18T14:33:33.8414506Z ERROR in node_modules/angular-2-local-storage/dist/local-storage.module.d.ts:4:65 - error TS2314: Generic type 'ModuleWithProviders' requires 1 type argument(s).
2021-01-18T14:33:33.8414883Z
2021-01-18T14:33:33.8415138Z 4 static withConfig(userConfig?: ILocalStorageServiceConfig): ModuleWithProviders;

IE adding addional double quote

Hi there,

I have noticed this application storing all values with double quotes in IE regardless of the type of the variable unlike chrome, where the values are saved as its type. This is creating issue for me to share the value with other sub-domain applications.

Even though session storage keys are same, angular-2-local-storage returning null for values set by other application.
Chrome output
image

IE output
image

Any helps appreciated!

Thanks in advance,
Sadik

Probably need to check config for null

I have a case when I need to create service with help of Injector.
this.injector.get(LocalStorageService);

Now, I get exception.

zone.js:643 Unhandled Promise rejection: Cannot read property 'notifyOptions' of undefined ; Zone: ; Task: Promise.then ; Value: TypeError: Cannot read property 'notifyOptions' of undefined
at new LocalStorageService (local-storage.service.js:34)

@phenomnomnominal Could you check please. I don't want to switch to another local storage service

Question: localstorage in a Angular2 Service

I am trying to get the local storage to persist some auth token info, and it is occurring in a service.
Strangly enough it does not seem to want to persist. If I redirect to the auth middleware (IdentityServer3) and then redirect back to the original site, the data I persisted is not there anymore. Is there something special I need to do to get localstorage to work for a service?

404 /angular-2-local-storage not found using seeds

I had problem and i spent more time to resolve that issue:

Solution:

SYSTEM_CONFIG_DEV: any = {
    defaultJSExtensions: true,
    packageConfigPaths: [
      ...
    ],
    paths: {
      ....
      'angular-2-local-storage': 'node_modules/angular-2-local-storage/dist/index.js',
       ...
    },
    packages: {
      'angular-2-local-storage': { 
        main: 'index.js', 
        defaultExtension: 'js' 
      } 
    }
  };

How to set and get values

Considering myself as a noob and couldnt figure out how to use setItem and getItem.
I am getting error at this point.
this.localStorage.setItems$.subscribe("cities", "Hello world");

What you published to npmjs seems messy and wrong. 0.0.19

It included *.d.ts files which is great. But it also included *.ts files.
messy

The result is if I try to use typescript to build my project into ES6/ES2015, I got errors like this:

error TS6059: File '/Users/gordon/workspace/CraigsMenu/web/node_modules/angular-2-local-storage/src/ILocalStorageEvent.ts' is not under 'rootDir' '/Users/gordon/workspace/CraigsMenu/web/app'. 'rootDir' is expected to contain all source files.

error TS6059: File '/Users/gordon/workspace/CraigsMenu/web/node_modules/angular-2-local-storage/src/ILocalStorageServiceConfig.ts' is not under 'rootDir' '/Users/gordon/workspace/CraigsMenu/web/app'. 'rootDir' is expected to contain all source files.

error TS6059: File '/Users/gordon/workspace/CraigsMenu/web/node_modules/angular-2-local-storage/src/INotifyOptions.ts' is not under 'rootDir' '/Users/gordon/workspace/CraigsMenu/web/app'. 'rootDir' is expected to contain all source files.

error TS6059: File '/Users/gordon/workspace/CraigsMenu/web/node_modules/angular-2-local-storage/src/LocalStorageService.ts' is not under 'rootDir' '/Users/gordon/workspace/CraigsMenu/web/app'. 'rootDir' is expected to contain all source files.

error TS6059: File '/Users/gordon/workspace/CraigsMenu/web/node_modules/angular-2-local-storage/src/LocalStorageServiceConfig.ts' is not under 'rootDir' '/Users/gordon/workspace/CraigsMenu/web/app'. 'rootDir' is expected to contain all source files.

My tsconfig.json file looks like this:

{
  "compilerOptions": {
    "target": "es2015",
    "module": "es2015",
    "moduleResolution": "node",
    "declaration": false,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "pretty": true,
    "allowUnreachableCode": false,
    "allowUnusedLabels": false,
    "noImplicitReturns": true,
    "noImplicitUseStrict": false,
    "noFallthroughCasesInSwitch": true,
    "outDir": "./dist",
    "rootDir": "./app"
  },
  "compileOnSave": false,
  "files": [
    "app/main.ts"
  ]
}

The build command is simply: tsc -p tsconfig.json

Angular 4 migration/support

I'm not sure if this is a problem with my code or this repository but I tried to use it with angular 4 and it failed (don't have the error message right now, can try it again if needed).
Are you aware of any limitations that will prevent this code from running with angular 4?

Setting prefix using a variable with aot enabled fails

Thanx for this great plugin!

I have a question. I am using angular 4.3.5 with angular cli 1.3.2 and compile my code with aot enabled.
How can i use a variable stored in global window-variable for prefix?

import { LocalStorageModule } from 'angular-2-local-storage';

// window.ownVariables.var1 is initialized in index.html !
const myVariable = `my-app-${window.ownVariables.var1}`;

@NgModule({
    imports: [
        LocalStorageModule.withConfig({
            prefix: `my-app-${myVariable}`,
            storageType: 'localStorage'
        })
    ],
    declarations: [
        ..
    ],
    providers: [
        ..
    ],
    bootstrap: [AppComponent]
})
export class AppModule {}

The variable myVaraible is undefined at compile time of aot. Do you have any ideas to solve this problem? Is there a possibility to set the prefix in another way?

es6 shim causing ts compilation error

Getting this error as a conflict between the es6 shim and core-js.

\node_modules@types\core-js\index.d.ts(21,14): error TS2300: Build:Duplicate identifier 'PropertyKey'.
\wwwroot\modules\angular-2-local-storage\typings\globals\es6-shim\index.d.ts(3,14): error TS2300: Build:Duplicate identifier 'PropertyKey'.

I've tried putting all manner of things in my ts.config exclude section but can't seem to get past this. Any ideas? Should the shim really be in there anyway?

a

a

not found error when running angular app

Promise fails.
zone.js:101 GET http://localhost:4200/angular-2-local-storage 404 (Not Found)

Any idea why this is happening? I'm using the angular cli
I added the npm and did the config as your documentation suggested. The module is found in the editor, I just get the error in the browser console when I run the app (ng serve).

Thanks

UPDATE:
It worked after I edited the system-config.ts

setItem$ Observable firing in component but not in directive

I'm setting a local storage variable by toggling a button. The subscribe is working as expected in the component it's being triggered from, but fires only the first time in the directive, subsequent changes are not picked up.

I feel like this might be an Angular thing, or how I've architected it, but just wondering if subscribing in directives is a known issue.

Change/Release notes for 3.x

I see there's a 3.0.1 release available via npm, and it's red-flagged as a major release with potentially breaking changes, but I can't find any release notes to know what's in this release, what may break (if anything), and where the test points are.

Am I looking in the wrong place, or are there release notes still coming?

Thanks!

Update to angular 7

While it appears to be working correctly, the version compatibility should be updated.

EXCEPTION: TypeError: this.warnings is undefined when localStorage disabled

Firefox: 49.0
After localStorage gets disabled in Firefox (about:config > dom.storage.enabled set to false)
Exception occurs:

ORIGINAL EXCEPTION: TypeError: this.warnings is undefined ORIGINAL STACKTRACE: LocalStorageService.prototype.get@http://localhost:5000/build/webdeps/angular-2-local-storage/LocalStorageService.js:85:13

TypeError: (intermediate value).share is not a function

I'm getting this error after i update to angular 5: ERROR TypeError: (intermediate value).share is not a function at new LocalStorageService (local-storage.service.js:45)

The error is at this line: this.errors$ = new Observable_1.Observable(function (observer) { return _this.errors = observer; }).share();

Anyone have any idea why it is happening?

Define Domain/Subdomain

would it be possible to define domain?

in an angular1x packet, there is a possibility, but I have not found anything 2x +.

ClearAll functionality

Hi, I read you use most of the code from angular-local-storage, but this method clearAll there has an optional parameter, the regex.

On angular-2-local-storage I'm obliged to inform the regex. My question is, if I do something like this this.localStorageService.clearAll(''); will it work the same way or you validate/require a regex for removal? If that's the case, do you plan on implementing that functionality?

Thanks!

Wrong source mapping url

In your index.js you have

//# sourceMappingURL=../../dist/index.js.map

This is wrong. After install, there is no dist folder

All you need is ./index.js.map
This also apply to all other js files created.

404 /angular-2-local-storage not found and systemjs.config.js

Hi,

I had to add

map { 
    ..., 
    'angular-2-local-storage': 'npm:angular-2-local-storage/dist'
}, 

and

packages: {       
    ..., 
    'angular-2-local-storage': { main: './angular-2-local-storage.js', defaultExtension: 'js' } 
}

to get angular-2-local-storage work as documented.

Otherwise I got 404 for /angular-2-local-storage requests.

Using v0.0.20 from via npm install.

I'm relatively new to all this npm and SystmJS stuff (been living in a cave for about five years now) so I just wanted to know if this is a "it's not a bug, it's a feature" case.

Angular 10 build problem

Hello , we are currently facing this problem when trying to ng build --prod ,
any solution for this?

ERROR in node_modules/angular-2-local-storage/local-storage.module.d.ts:4:62 - error TS2314: Generic type 'ModuleWithProviders<T>' requires 1 type argument(s).
 4     static forRoot(userConfig?: ILocalStorageServiceConfig): ModuleWithProviders; 

Make configuration optional

I really don't want to configure anything when using local storage. It would be great if we could make the LOCAL_STORAGE_SERVICE_CONFIG provider optional

Error on compiling with angular 2

get _LocalStorageService_75():import44.LocalStorageService { if ((this.__LocalStorageService_75 == (null as any))) { (this.__LocalStorageService_75 = new import44.LocalStorageService()); } return this.__LocalStorageService_75; }

ngc : Error : [ts] Supplied parameters do not match any signature of call target.
constructor LocalStorageService(config: ILocalStorageServiceConfig): import44.LocalStorageService

How to use it in the template ?

Hi,

How to store a value from an input text and then retrieve it in the component ?

ex : <input type="text" [(ngModel)]="number">

And in my component do something like this : @LocalStorageService() public number:number

It will be nice to put a complete example

rxjs pipe() ?

im using lib in my project

Angular CLI: 6.0.0-rc.2
Node: 8.11.1
OS: win32 x64
Angular: 6.0.0-rc.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cdk: 6.0.0-rc.1
@angular/cli: 6.0.0-rc.2
@angular/material: 6.0.0-rc.1
@angular-devkit/architect: 0.5.4
@angular-devkit/build-angular: 0.5.4
@angular-devkit/build-optimizer: 0.5.4
@angular-devkit/core: 0.5.4
@angular-devkit/schematics: 0.5.4
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 6.0.0-rc.2.4
@schematics/angular: 0.5.4
@schematics/update: 0.5.4
typescript: 2.7.2
webpack: 4.5.0

it was working on 1.7.4 with 5.x rxjs

today i tried to update to cli rc2 and rxjs rx1 and got this


ERROR in ./node_modules/angular-2-local-storage/dist/local-storage.service.js
Module not found: Error: Can't resolve 'rxjs/Observable' in 'C:...node_modules\angular-2-local-storage\dist'

ERROR in ./node_modules/angular-2-local-storage/dist/local-storage.service.js
Module not found: Error: Can't resolve 'rxjs/Subscriber' in 'C:...node_modules\angular-2-local-storage\dist'

ERROR in ./node_modules/angular-2-local-storage/dist/local-storage.service.js
Module not found: Error: Can't resolve 'rxjs/add/operator/share' in 'C:...node_modules\angular-2-local-storage\dist'

can you maybe update new rxjs syntax using pipe() thanks

Additional usage case

Is it possible to add more use cases?

  1. Getting object and cast to custom model
  2. Set custom objet
  3. Usage with RxJS

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.