Giter Site home page Giter Site logo

ngx-cookie's People

Contributors

brolaugh avatar chimurai avatar dependabot[bot] avatar jjozwiak avatar l7960261 avatar mstarski avatar salemdar avatar waog avatar wolfsoko 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  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ngx-cookie's Issues

Error in setting and removing cookies when using angular universal

I'm submitting a ... (check one with "x")

[ x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
When using universal, I am receiving the following error

ERROR TypeError: Cannot set property 'cookie' of undefined
    at CookieBackendService.set [as cookieString] (/Users/melliotfrost/projects/pensar/pensar-microlearning/node_modules/ngx-cookie/bundles/ngx-cookie.umd.js:477:46)
    at /Users/melliotfrost/projects/pensar/pensar-microlearning/node_modules/ngx-cookie/bundles/ngx-cookie.umd.js:400:39
    at CookieBackendService.CookieService.remove (/Users/melliotfrost/projects/pensar/pensar-microlearning/node_modules/ngx-cookie/bundles/ngx-cookie.umd.js:328:37)
    at l.removeToken (/Users/melliotfrost/projects/pensar/pensar-microlearning/dist/server.js:1:1311643)
    at SafeSubscriber._error (/Users/melliotfrost/projects/pensar/pensar-microlearning/dist/server.js:1:1308071)
    at SafeSubscriber.__tryOrUnsub (/Users/melliotfrost/projects/pensar/pensar-microlearning/node_modules/rxjs/Subscriber.js:239:16)
    at SafeSubscriber.error (/Users/melliotfrost/projects/pensar/pensar-microlearning/node_modules/rxjs/Subscriber.js:198:26)
    at Subscriber._error (/Users/melliotfrost/projects/pensar/pensar-microlearning/node_modules/rxjs/Subscriber.js:129:26)
    at Subscriber.error (/Users/melliotfrost/projects/pensar/pensar-microlearning/node_modules/rxjs/Subscriber.js:103:18)
    at MapSubscriber.Subscriber._error (/Users/melliotfrost/projects/pensar/pensar-microlearning/node_modules/rxjs/Subscriber.js:129:26)

Expected/desired behavior
Should be able to remove and set token when using universal

Reproduction of the problem
Just follow the steps mentioned in the readme of this repository.

What is the expected behavior?
No error on setting and removing cookies.

What is the motivation / use case for changing the behavior?
To get this library working with Universal

Please tell us about your environment:

  • ngx-cookie version: 4.0.2

  • Angular version: 5.2.8

  • Browser: Chrome

Expose COOKIE_OPTIONS and CookieOptionsProvider tokens

Hi,

Could you please release the changes made to https://github.com/salemdar/ngx-cookie/blob/master/index.ts?

I need COOKIE_OPTIONS to specify options with a factory, and I also extend CookieService and add some custom methods on top of it (that also use CookieOptions), in case you are wondering about use cases.

For now I use
import { COOKIE_OPTIONS, CookieOptionsProvider } from 'ngx-cookie/src/cookie-options-provider';, but it would be nicer to just import these from ngx-cookie.

Cannot install this package in angular 4.3.6

I'm submitting a ... (check one with "x")

[x ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
Cannot install this package in angular 4.3.6

Expected/desired behavior
Should be able to install the package.

Reproduction of the problem
`$ npm install ngx-cookie --save
C:\xampp\htdocs\angular4
+-- UNMET PEER DEPENDENCY @angular/[email protected]
+-- UNMET PEER DEPENDENCY @angular/[email protected]
-- [email protected]

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN enoent ENOENT: no such file or directory, open 'C:\xampp\htdocs\angular4\node_modules\es5-ext\package.json'
npm WARN [email protected] requires a peer of @angular/common@^2.0.0 but none was installed.
npm WARN [email protected] requires a peer of @angular/core@^2.0.0 but none was installed.
`

What is the expected behavior?
Able to install the package

What is the motivation / use case for changing the behavior?

Please tell us about your environment:
Windows 8.1

  • ngx-cookie version: 1.2.6

  • Angular version: 4.3.6

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
    All

ngx-cookie won't compile with Angular CLI 1.6.0

I'm submitting a ... (check one with "x")

[ ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior

Build freezes at 70% with the error

Expected/desired behavior

Error free compilation

Reproduction of the problem
If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar.

ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
16% building modules 50/59 modules 9 active ...tion\node_modules\ngx-cookie\index.jsError: No module factory available for dependency type: ContextElementDependency
at Compilation.addModuleDependencies (C:\git-hcm\optimizer2\Presentation\node_modules@angular\cli\node_modules\webpack\lib\Compilation.js:215:21)
at Compilation.processModuleDependencies (C:\git-hcm\optimizer2\Presentation\node_modules@angular\cli\node_modules\webpack\lib\Compilation.js:204:8)
at _this.buildModule.err (C:\git-hcm\optimizer2\Presentation\node_modules@angular\cli\node_modules\webpack\lib\Compilation.js:359:14)
at building.forEach.cb (C:\git-hcm\optimizer2\Presentation\node_modules@angular\cli\node_modules\webpack\lib\Compilation.js:149:27)
at Array.forEach ()
at callback (C:\git-hcm\optimizer2\Presentation\node_modules@angular\cli\node_modules\webpack\lib\Compilation.js:149:13)
at module.build (C:\git-hcm\optimizer2\Presentation\node_modules@angular\cli\node_modules\webpack\lib\Compilation.js:176:11)
at resolveDependencies (C:\git-hcm\optimizer2\Presentation\node_modules@angular\cli\node_modules\webpack\lib\ContextModule.js:165:4)
at ContextModule.result.resolveDependencies (C:\git-hcm\optimizer2\Presentation\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:431:25)
at ContextModule.build (C:\git-hcm\optimizer2\Presentation\node_modules@angular\cli\node_modules\webpack\lib\ContextModule.js:105:8)
at Compilation.buildModule (C:\git-hcm\optimizer2\Presentation\node_modules@angular\cli\node_modules\webpack\lib\Compilation.js:151:10)
at factoryCallback (C:\git-hcm\optimizer2\Presentation\node_modules@angular\cli\node_modules\webpack\lib\Compilation.js:344:12)
at C:\git-hcm\optimizer2\Presentation\node_modules@angular\cli\node_modules\webpack\lib\ContextModuleFactory.js:95:13
at C:\git-hcm\optimizer2\Presentation\node_modules\tapable\lib\Tapable.js:268:11
at done.then (C:\git-hcm\optimizer2\Presentation\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:433:28)
at 70% building modules 1809/1809 modules 0 active^CTerminate batch job (Y/N)? y

What is the expected behavior?

    Error free build

What is the motivation / use case for changing the behavior?

    N/A

Please tell us about your environment:

    "ngx-cookie": "^2.0.1",

    "@angular/cli": "1.6.0-rc.2",
    "@angular/compiler-cli": "5.1.0",
    "@angular/core": "5.1.0",
    "@angular/language-service": "4.4.3",

    "@angular/cdk": "5.0.0",
    "@angular/material": "5.0.0",
    "@angular/common": "5.1.0",
    "@angular/animations": "5.1.0",
    "@angular/compiler": "5.1.0",
    "@angular/forms": "5.1.0",
    "@angular/http": "5.1.0",
    "@angular/platform-browser": "5.1.0",
    "@angular/platform-browser-dynamic": "5.1.0",
    "@angular/platform-server": "5.1.0",
    "@angular/router": "5.1.0",
  • Browser:

      Chrome 62.0.3202.94 (Official Build) (64-bit)
    
  • Notes:

ngx-cookie builds with all versions of angular/cli 1.6.0-rc.1 and below.

An in-range update of @types/node is breaking the build 🚨

The devDependency @types/node was updated from 10.9.4 to 10.10.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@types/node is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Cannot read property 'OpaqueToken' of undefined

I'm submitting a ... (check one with "x")

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
Getting error with angular-cli:

Uncaught TypeError: Cannot read property 'OpaqueToken' of undefined
    at Object.__webpack_exports__.d (eval at webpackJsonp.523.module.exports (addScript.js:9), <anonymous>:301:69)
    at __webpack_require__ (eval at webpackJsonp.523.module.exports (addScript.js:9), <anonymous>:30:30)
    at Object.eval (eval at webpackJsonp.523.module.exports (addScript.js:9), <anonymous>:487:87)
    at __webpack_require__ (eval at webpackJsonp.523.module.exports (addScript.js:9), <anonymous>:30:30)
    at eval (eval at webpackJsonp.523.module.exports (addScript.js:9), <anonymous>:76:18)
    at eval (eval at webpackJsonp.523.module.exports (addScript.js:9), <anonymous>:79:10)
    at webpackUniversalModuleDefinition (eval at webpackJsonp.523.module.exports (addScript.js:9), <anonymous>:9:24)
    at eval (eval at webpackJsonp.523.module.exports (addScript.js:9), <anonymous>:10:3)
    at eval (<anonymous>)
    at webpackJsonp.523.module.exports (addScript.js:9)
    at Object.330 (ngx-cookie.umd.js?2ab6:1)
    at __webpack_require__ (bootstrap cb8ca3d…:52)
    at Object.562 (addScript.js:10)
    at __webpack_require__ (bootstrap cb8ca3d…:52)
    at webpackJsonpCallback (bootstrap cb8ca3d…:23)

Please tell us about your environment:

  • ngx-cookie version: 1.0.0

  • Angular version: 2.4.9

  • Browser: [ all ]

Cookies not saved on iOS WebView app

I'm submitting a ... (check one with "x")

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
Saving the cookie on iOS app "webview app just like Ionic app" doesn't work and it gets deleted when reload the application.

Expected/desired behavior
The cookies should be saved and successfully retrieved when reload the app

Reproduction of the problem
generate new application using Ionic CLI "or ngx rocket CLI"
install ngx-cookie
setup your service for connection
save the Authentication session in cookies
reload the application
try to get the cookies

What is the expected behavior?
the cookies should be saved and retrieved successfully after reloading the app

What is the motivation / use case for changing the behavior?
i am not sure if it is an iOS issue or it can be handled by ngx-cookie , actually everything is working fine on all the other browsers and platforms and even on Android webview

Please tell us about your environment:
Its an Ionic application for Android and iOS, using Drupal backend, as usual Drupal authentication goes by setting token, session_name and sessid cookies on the browser or on the header, but only on iOS it doesn't save the cookies and also doesn't send them with the headers "this is another problem also with angular httpClient"
you can use my Drupal services package and check what i am talking about.

  • ngx-cookie version: 2.0.1

  • Angular version: 5.2.5

  • Browser: [iOS XX UIWebView | iOS XX WKWebView ]

Error thrown when application launched

I'm submitting a ... (check one with "x")

[x ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
Starting a simple Angular 5 application throws an error in the Chrome dev console:

compiler.js:466 Uncaught Error: Unexpected value '[object Object]' imported by the module 'AppModule'. Please add a @NgModule annotation.
    at syntaxError (compiler.js:466)
    at eval (compiler.js:15088)
    at Array.forEach (<anonymous>)
    at CompileMetadataResolver.getNgModuleMetadata (compiler.js:15071)
    at JitCompiler._loadModules (compiler.js:33486)
    at JitCompiler._compileModuleAndComponents (compiler.js:33447)
    at JitCompiler.compileModuleAsync (compiler.js:33363)
    at CompilerImpl.compileModuleAsync (platform-browser-dynamic.js:230)
    at PlatformRef.bootstrapModule (core.js:5446)
    at eval (main.ts:10)

removing the line CookieModule.forRoot() in the [imports] of the app.module.ts file eliminated the exception.

Expected/desired behavior
Don't throw exception.

Please tell us about your environment:

  • ngx-cookie version: 2.0.0

  • Angular version:

Node: 8.8.1
OS: linux x64
Angular: 5.0.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cdk: 5.0.0-rc0
@angular/cli: 1.5.0
@angular/flex-layout: 2.0.0-beta.10-4905443
@angular/material: 5.0.0-rc0
@angular-devkit/build-optimizer: 0.0.32
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.0
typescript: 2.4.2
webpack: 3.8.1
  • Browser: Chrome

Can't read cookie from Secure or Http checked cookie.

I'm submitting a ... (check one with "x")

[ ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ X ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior

I'm trying to parse a cookie using the .get method. Everything works perfectly in local with unsecured cookies. However, when I deploy to dev on a secure URL, the .get returns undefined for the cookie value.

Please tell us about your environment:

  • ngx-cookie version: Current

  • Angular version: 4.0.0

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Cookie not getting deleted by remove('cookie_name') and removeAll()

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
Unable to delete cookie. To set cookie I am using:

setCookie(cookie: string) {
    this.cookieService.put('userDetails', JSON.stringify(cookie), { domain: 'localhost' });
}

Expected/desired behavior

logout() {
    this.securityService.setLoginStatus(false);
    console.log('cookie details before: ' + JSON.stringify(this.cookie));
    this.socketService.logout(JSON.parse(this.cookie).id);
    this.cookieService.remove('userDetails', { domain: 'localhost' });
    console.log('cookie details after: ' + JSON.stringify(this.cookie));
 }

It is still showing the cookie in application tab. And after remove() also the cookie details is getting printed.

Breaking change 1.0.0 => 1.0.1

I'm submitting a ... (check one with "x")

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

When building with @angular/core 2.4.5, running the webpack bundle command shows this error:
WARNING in ./~/ngx-cookie/src/cookie-options-provider.js
4:32-46 "export 'InjectionToken' was not found in '@angular/core'

ERROR in [at-loader] ./node_modules/ngx-cookie/src/cookie-options-provider.d.ts:1:10
TS2305: Module '"F:/A3/_w/40/s/OnlineOrdering/node_modules/@angular/core/index"' has no exported member 'InjectionToken'.

Expected/desired behavior
Desired behavior is to publish with no errors. This works with version 1.0.0, but breaks with version 1.0.1, which was unexpected.

Reproduction of the problem
create a new template using the command "dotnet new angular" and set the package.json the same as I show below. Try to build using the webpack bundle command. You will see the error message.

node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js

What is the expected behavior?
Should build with no errors

What is the motivation / use case for changing the behavior?

Please tell us about your environment:
Our project was based on the ASP.NET template project, created with the command "dotnet new angular", which builds a SPA application using ASP.NET backend and Angular/typescript front end, with webpack as the bundler.

  • ngx-cookie version: 1.0.0 -> 1.0.1

  • Angular version: 2.4.5

  • Browser: [all ]

My package.json file:

"dependencies": { "@angular/common": "^2.4.5", "@angular/compiler": "^2.4.5", "@angular/core": "^2.4.5", "@angular/forms": "^2.4.5", "@angular/http": "^2.4.5", "@angular/platform-browser": "^2.4.5", "@angular/platform-browser-dynamic": "^2.4.5", "@angular/platform-server": "^2.4.5", "@angular/router": "^3.4.5", "@ng-idle/core": "^2.0.0-beta.12", "@ng-idle/keepalive": "^2.0.0-beta.12", "@types/node": "^6.0.42", "angular2-cool-http": "~2.1.0", "angular2-jwt": "^0.2.3", "angular2-platform-node": "~2.0.11", "angular2-template-loader": "^0.6.2", "angular2-universal": "^2.1.0-rc.1", "angular2-universal-patch": "^0.2.1", "angular2-universal-polyfills": "^2.1.0-rc.1", "aspnet-prerendering": "^2.0.0", "aspnet-webpack": "^1.0.17", "awesome-typescript-loader": "^3.0.0", "bootstrap": "^3.3.7", "css": "^2.2.1", "css-loader": "^0.25.0", "es6-shim": "^0.35.1", "event-source-polyfill": "^0.0.7", "expose-loader": "^0.7.1", "extract-text-webpack-plugin": "^2.0.0-rc", "file-loader": "^0.9.0", "font-awesome": "4.7.0", "html-loader": "^0.4.4", "isomorphic-fetch": "^2.2.1", "jquery": "^2.2.1", "json-loader": "^0.5.4", "ng2-toastr": "1.3.3", "ngx-cookie": "^1.0.0", "ngx-mydatepicker": "2.0.12", "preboot": "^4.5.2", "raw-loader": "^0.5.1", "rxjs": "^5.0.1", "style-loader": "^0.13.1", "to-string-loader": "^1.1.5", "typescript": "^2.2.1", "url-loader": "^0.5.7", "webpack": "^2.2.0", "webpack-hot-middleware": "^2.12.2", "webpack-merge": "^0.14.1", "zone.js": "^0.7.6" }, "devDependencies": { "@types/chai": "^3.4.34", "@types/jasmine": "^2.5.37", "chai": "^3.5.0", "jasmine": "^2.6.0", "jasmine-core": "^2.5.2", "karma": "^1.7.0", "karma-chai": "^0.1.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-webpack": "^1.8.0" }

Can't resolve 'ngx-cookie/src/cookie.service'

I'm submitting a ... (check one with "x")

[ X ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
Unable to locate file

Expected/desired behavior
Able to locate file

Reproduction of the problem
Create a service file that include CookieService in the constructor, also do the same in a component, when ng-packagr compules using ng6 the output will do this (in the fesm file):
import { CookieService, CookieModule } from 'ngx-cookie';
import { CookieService as CookieService$1 } from 'ngx-cookie/src/cookie.service';

What is the expected behavior?
import { CookieService, CookieModule } from 'ngx-cookie';
(not having the cookieservice ad $1

What is the motivation / use case for changing the behavior?
you cant build packages with it

Please tell us about your environment:
angular 6 latest building with a livrary

  • ngx-cookie version: 4.0.2

  • Angular version: 6+

NodeInvocationException: No provider for CookieService!

Hi,
I'm submitting a

[X] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
I follow the instructions in the read.me file of this project. When I start the app I get the following error in the browser:

An unhandled exception occurred while processing the request.

NodeInvocationException: No provider for CookieService!
Error: No provider for CookieService!
at injectionError ( ... \ClientApp\dist\vendor.js:12066:90)
at noProviderError ( ... \ClientApp\dist\vendor.js:12104:12)
at ReflectiveInjector_.module.exports.ReflectiveInjector_._throwOrNull ( ... \ClientApp\dist\vendor.js:13546:19)
at ReflectiveInjector_.module.exports.ReflectiveInjector_._getByKeyDefault ( ... \ClientApp\dist\vendor.js:13585:25)
at ReflectiveInjector_.module.exports.ReflectiveInjector_._getByKey ( ... \ClientApp\dist\vendor.js:13517:25)
at ReflectiveInjector_.module.exports.ReflectiveInjector_.get ( ... \ClientApp\dist\vendor.js:13386:21)
at resolveNgModuleDep ( ... \ClientApp\dist\vendor.js:20430:25)
at NgModuleRef_.module.exports.NgModuleRef_.get ( ... \ClientApp\dist\vendor.js:21512:16)
at resolveDep ( ... \ClientApp\dist\vendor.js:22015:45)
at createClass ( ... \ClientApp\dist\vendor.js:21874:147)
Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance+<InvokeExportAsync>d__7.MoveNext()

Expected/desired behavior
I expected the app to start without error. :)

Reproduction of the problem
I import CookieModule in the app module and import CookieService in the component.
Then I DI it into the constructor of the component. I do not even call it, just declare.
When I remove the imports and the DI, the project starts correctly.

app.module.browser.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { CookieModule } from 'ngx-cookie';
import { AppModuleShared } from './app.module.shared';
import { AppComponent } from './components/app/app.component';

@NgModule({
    bootstrap: [AppComponent],
    imports: [BrowserModule, AppModuleShared, CookieModule.forRoot()],
    providers: [ { provide: 'BASE_URL', useFactory: getBaseUrl }  ]
})
export class AppModule { }
export function getBaseUrl() {
    return document.getElementsByTagName('base')[0].href;
}

setlanguage.component.ts

import { Component, Inject } from '@angular/core';
import { Http } from '@angular/http';
import { CookieService } from 'ngx-cookie';

@Component({
    selector: 'setlanguage',
    templateUrl: './setlanguage.component.html'
})
export class SetLanguageComponent {
    constructor(private http: Http, @Inject('BASE_URL') private baseUrl: string,
        private _cookieService: CookieService) {
    }
}

Please tell us about your environment:

  • ASP.NET Core 2.0

  • VISUAL STUDIO 2017 community 15.4.5

  • Webpack 2.5.1

  • Windows 10

  • ngx-cookie version: 2.0.1

  • Angular version: 4.2.5

  • Browser: [Chrome 62]

Any help would be appreciated.

Universal Rendering throws "window is not defined" error

I'm submitting a ... (check one with "x")

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
On following the steps mentioned in the documentation.

In \dist\server.js:322779

!function(e,t){ true?module.exports=t(webpack_require(0),webpack_require(4)):"function"==typeof define&&define.amd?define(["@angular/core","@angular/common"],t):"object"==typeof exports?exports["ngx-cookie"]=t(require("@angular/core"),require("@angular/common")):e["ngx-cookie"]=t(e["@angular/core"],e["@angular/common"])}(window,function(e,t){return function(e){var t={};function o(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=e,o.c=t,o.d=function(e,t,r){o.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},o.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/",o(o.s=7)}([function(e,t,o){"use strict";var r=this&&this.__decorate||function(e,t,

ReferenceError: window is not defined

Expected/desired behavior
Should compile fine as mentioned in the docs.

Reproduction of the problem
Just follow the steps mentioned in the readme of this repository.

What is the expected behavior?
No compilation errors.

What is the motivation / use case for changing the behavior?
To get this library working with Universal

Please tell us about your environment:

  • ngx-cookie version: ^3.0.1

  • Angular version: ^5.2.9

  • Browser: Chrome

ngx-cookie support for Angular Universal

I'm submitting a ... (check one with "x")

[ ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[X] feature request

Current behavior

Current implementation of the CookieBackendService doesn't work with the current angular universal. The request / response aren't available in the current Zone as is currently the way to use it in the CookieBackendService implementation.

Expected/desired behavior

There is a fork of ngx-cookie which looks to address this issue:

jzahka@d5bc30c

So for the looks it would probably be fixed by getting that commit into ngx-cookie.

I tried to use that fork in my project, but didn't figure out how to do a post install build that works. The published ngx-cookie is compiled / build differently than what I can seem to be triggering.

Please tell us about your environment:

  • ngx-cookie version: 1.0.0

  • Angular version: 4.1.3

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Replaced the old Node.js version in your .nvmrc with the new one

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Compilation error after installing

I'm submitting/facing a query / bug ...
Error

ERROR in Metadata version mismatch for module XXX/node_modules/ngx-cookie/index.d.ts, found version 4, expected 3, resolving symbol AppModule in XXX/src/app/app.module.ts, resolving symbol AppModule in XXX//src/app/app.module.ts, resolving symbol AppModule in XXX/src/app/app.module.ts

Its and compilation error. let me know what step is require to solve this.

Reproduction of the problem
I have install the ngx-cookie using "npm install ngx-cookie --save" and then added CookieModule and CookieService to the respective files. Also, added the CookieModule.forRoot() in my app.module file.
After all this step when i execute the npm start. It gives me given error.

Environment:

  • ngx-cookie version: 2.0.1

  • Angular version: 2.x.x

  • Browser: N/A

Error on Heroku Deployment

Error in Heroku deployment

client/app/app.module.ts(12,30): error TS2307: Cannot find module 'ngx-cookie'.
client/service/user.service.ts(5,29): error TS2307: Cannot find module 'ngx-cookie'.
  • ngx-cookie version: 1.0.0

  • Angular version: 4.0.0

Provide CookieOptions not working anymore after migrating to version 4

I'm submitting a ... (check one with "x")

[ ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[x] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
"ERROR in src/app/app.module.ts(158,56): error TS2693: 'CookieOptions' only refers to a type, but is being used as a value here.
"

Expected/desired behavior
Work like before, when I used version 1.2.6.

Reproduction of the problem

import {CookieService, CookieOptions} from 'ngx-cookie';
[...]
@NgModule({
[...]
providers: [CookieService, {provide: CookieOptions, useValue: {}}],
[..]

ng build

Please tell us about your environment:
Windows 10, Angular 6, Angular CLI 6, nodejs 8, npm 5

  • ngx-cookie version: 4.0.2

  • Angular version: 6.1.4

  • Browser:
    all

Not Deleting Cookies

I'm submitting a ... (check one with "x")

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
When calling cookies.removeAll or cookies.remove functions the cookies are not deleted and are still persisted in browser

Expected/desired behavior
I expect the cookies to be deleted

Reproduction of the problem
If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar.
This is in TS, so I cannot reproduce in plnkr. But I can share some code. I have 2 modules, an app.modules, which is my main module, and a core.module which holds all core app components and services. I included the CookieModule.forRoot() to the app module as directed in the usage as well as in my core module, where i have tried CookieModule.forChild() and forRoot() with no avail.

App Module

@NgModule({
  imports: [
    CoreModule,
    CookieModule.forRoot(),
    BrowserModule,
    AppRoutingModule,
    SharedModule,
    LoginModule
  ],

Core Module

@NgModule({
  imports: [
    HttpModule,
    CommonModule,
    FormsModule,
    CookieModule.forChild()
  ],

Then within my service in Core module I inject the service using my constructor and use the cookies service as follows:

constructor(private cookies: CookieService) {
  }

  public logout() {
    this.sessionStorage.clear();
    this.cookies.remove('auth.token');
    //cookie is still there with same value
    console.log('auth token cookie::', this.cookies.get('auth.token'));
    this.setLoggedIn(false);
  }

When i console.log the output i see the token after its supposed to be deleted.

In addition, Im using webpack 2 and am importing ngx-cookie in my vendor.browser.ts like so:

import 'ngx-cookie';

What is the expected behavior?
I expect the cookie auth.token to be removed.

Please tell us about your environment:

  • **ngx-cookie version:**0.0.0-development - as seen in package.json

  • Angular version: 4.1.0-beta.1

  • Browser: [ Chrome: 58.0.3029.81 (64-bit)]

Cookies as token containers

Hi there.

I'm wondering if there is a guide that explain how to use the Cookie as storage of access/refresh token in angular2.

It seems that everyone admit the benefits fo Cookies in auth protocol via angular, but i can't find reference, and i've problems refreshing the token inside the cookie!

DIST is missing all CookieOptions files.

I'm submitting a ... (check one with "x")

[ ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

can you please provide those files in the dist?

Current behavior

Expected/desired behavior

Reproduction of the problem
If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar.

What is the expected behavior?

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • ngx-cookie version: x.x.x

  • Angular version: 2.x.x

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Test failure after installation

I'm submitting a ... (check one with "x")

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
After I installed ngx-cookie on my angular-seed per the instructions I can no longer run "npm test" on my application. I'm getting the following error when I run "npm test"

404: /base/node_modules/ngx-cookie/bundles/ngx-cookie.umd.js
Chrome 60.0.3112 (Windows 10 0.0.0) ERROR: 'Error: Fetch error: 404 Not Found
    at http://localhost:9876/base/node_modules/systemjs/dist/system.src.js?aebe9c95220342ad600bf928e092893ef1e9c861:1478:13
    at ZoneDelegate.invoke (http://localhost:9876/base/node_modules/zone.js/dist/zone.js?082dc1d83c7a42ddda9b652319d281eef1d450d5:391:26)
    at Zone.run (http://localhost:9876/base/node_modules/zone.js/dist/zone.js?082dc1d83c7a42ddda9b652319d281eef1d450d5:141:43)
    at http://localhost:9876/base/node_modules/zone.js/dist/zone.js?082dc1d83c7a42ddda9b652319d281eef1d450d5:818:57
    at ZoneDelegate.invokeTask (http://localhost:9876/base/node_modules/zone.js/dist/zone.js?082dc1d83c7a42ddda9b652319d281eef1d450d5:424:31)
    at Zone.runTask (http://localhost:9876/base/node_modules/zone.js/dist/zone.js?082dc1d83c7a42ddda9b652319d281eef1d450d5:191:47)
    at drainMicroTaskQueue (http://localhost:9876/base/node_modules/zone.js/dist/zone.js?082dc1d83c7a42ddda9b652319d281eef1d450d5:584:35)
    at <anonymous>'
Chrome 60.0.3112 (Windows 10 0.0.0) ERROR: 'Error: Fetch error: 404 Not Found
    at http://localhost:9876/base/node_modules/systemjs/dist/system.src.js?aebe9c95220342ad600bf928e092893ef1e9c861:1478:13
    at ZoneDelegate.invoke (http://localhost:9876/base/node_modules/zone.js/dist/zone.js?082dc1d83c7a42ddda9b652319d281eef1d450d5:391:26)
    at Zone.run (http://localhost:9876/base/node_modules/zone.js/dist/zone.js?082dc1d83c7a42ddda9b652319d281eef1d450d5:141:43)
    at http://localhost:9876/base/node_modules/zone.js/dist/zone.js?082dc1d83c7a42ddda9b652319d281eef1d450d5:818:57
    at ZoneDelegate.invokeTask (http://localhost:9876/base/node_modules/zone.js/dist/zone.js?082dc1d83c7a42ddda9b652319d281eef1d450d5:424:31)
    at Zone.runTask (http://localhost:9876/base/node_modules/zone.js/dist/zone.js?082dc1d83c7a42ddda9b652319d281eef1d450d5:191:47)
    at drainMicroTaskQueue (http://localhost:9876/base/node_modules/zone.js/dist/zone.js?082dc1d83c7a42ddda9b652319d281eef1d450d5:584:35)
    at <anonymous>'

Expected/desired behavior
proper execution of "npm tet"

What is the motivation / use case for changing the behavior?
Proper testing of code after module installation

Please tell us about your environment:
Angular2 using angular-seed as base

  • ngx-cookie version: 1.0.0

  • Angular version: 4.3.6

Error: No provider for CookieService! while doing ng test

Error: No provider for CookieService! while doing ng test (check one with "ng test")

Error: No provider for CookieService!
            at injectionError (webpack:///~/@angular/core/@angular/core.es5.js:1231:21 <- src/test.ts:1538:86)
            at noProviderError (webpack:///~/@angular/core/@angular/core.es5.js:1269:0 <- src/test.ts:1576:12)
  • Angular version: 1.0.0

  • Angular version: 4.1.2

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Uncaught (in promise): Error: No provider for t!

I'm submitting a ... (check one with "x")

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
am getting this error only when build for production

ERROR Error: Uncaught (in promise): Error: No provider for t!
Error: No provider for t!
at S (vendor.8a7e477….bundle.js:207)
at T (vendor.8a7e477….bundle.js:207)
at t._throwOrNull (vendor.8a7e477….bundle.js:354)
at t._getByKeyDefault (vendor.8a7e477….bundle.js:354)
at t._getByKey (vendor.8a7e477….bundle.js:354)
at t.get (vendor.8a7e477….bundle.js:354)
at n.get [as _SiteAuth_85] (main.3ea622e….bundle.js:1)
at n.get [as _RouteGuard_86] (main.3ea622e….bundle.js:1)
at n.getInternal (main.3ea622e….bundle.js:1)
at n.t.get (vendor.8a7e477….bundle.js:368)
at S (vendor.8a7e477….bundle.js:207)
at T (vendor.8a7e477….bundle.js:207)
at t._throwOrNull (vendor.8a7e477….bundle.js:354)
at t._getByKeyDefault (vendor.8a7e477….bundle.js:354)
at t._getByKey (vendor.8a7e477….bundle.js:354)
at t.get (vendor.8a7e477….bundle.js:354)
at n.get [as _SiteAuth_85] (main.3ea622e….bundle.js:1)
at n.get [as _RouteGuard_86] (main.3ea622e….bundle.js:1)
at n.getInternal (main.3ea622e….bundle.js:1)
at n.t.get (vendor.8a7e477….bundle.js:368)
at c (polyfills.5aae015….bundle.js:43)
at c (polyfills.5aae015….bundle.js:43)
at polyfills.5aae015….bundle.js:43
at t.invokeTask (polyfills.5aae015….bundle.js:36)
at Object.onInvokeTask (vendor.8a7e477….bundle.js:368)
at t.invokeTask (polyfills.5aae015….bundle.js:36)
at r.runTask (polyfills.5aae015….bundle.js:36)
at o (polyfills.5aae015….bundle.js:36)
at

@angular/cli: 1.0.2
@angular : 4.1.1

and i followed the last documentation steps

Expected/desired behavior

Reproduction of the problem
If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar.

What is the expected behavior?

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • ngx-cookie version: 1.0.0

  • Angular version: 4.1.1

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Can not get cookie value when navigate to the path that the cookie options set

I'm submitting a ... (check one with "x")

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
I set the cookie in specified path throuth CookieOptions:

  const options = {path:'/login'}
  this.cookieService.put("account", account,options);

When i navigate to the path through router,i can not get the value.

router.navigateByUrl("/login");

But if i request the url directly in browser, i can get the cookie value.

Expected/desired behavior

navigating to the path through router can get the cookie value.

Reproduction of the problem
I guess when using router to navigate, angular does not send a http request, for browser, the request url still is the old one, so can not get the cookie value.

Please tell us about your environment:

  • ngx-cookie version: 1.0.0

  • Angular version: 4.0.0

  • Browser: Chrome 58 | Firefox 54 | IE 11 ]

bump angular dependency to ^5.0.0

I'm submitting a ...
[ ] bug report
[x] feature request
[ ] question about the decisions made in the repository

Can you update the angular dependency to v5?

SyntaxError: Unexpected token import when used on the server-side

Currently ngx-cookie breaks when used on the server-side as explained in angular/angular-cli#7200. In short, when targeting the server platform with the Angular CLI only the app itself is compiled, as the libraries' UMD bundles would then be used when running it in NodeJS. However, when said library is published at separate ES modules instead of a flatten one (FESM), the deep imports would then resolved to the ES modules (and not the UMD bundle) on the server-side, causing Node to fail as it doesn't understand ES modules (v8.5 does with a special flag, but only with the .mjs file extension):

/foo/node_modules/ngx-cookie/src/cookie.service.js:1
(function (exports, require, module, __filename, __dirname) { import { Injectable } from '@angular/core';
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:588:28)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.ngx-cookie/src/cookie.service (/foo/universal/dist/main.bundle.js:31147:18)

Flattening the ESM output fixes that, and is also a best practice as per the Angular Package Format guidelines as it allows for faster builds, and makes sure that private imports aren't being used.

Settings passed with forRoot are not being preserved with angular-cli build

I'm submitting a ... (check one with "x")

[*] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
When using angular-cli --prod option settings passed to CookieModule.forRoot are omitted.

Expected/desired behavior
When using angular-cli --prod option settings passed to CookieModule.forRoot are there.

Reproduction of the problem
Create a module, import CookieModule and set expires
CookieModule.forRoot({
expires: new Date(24 * 60 * 60 * 1000 + Date.now())
}),

What is the expected behavior?
It should keep settings

Please tell us about your environment:

  • ngx-cookie version: 1.0.0

  • Angular version: 4.2.2

  • Browser: [all]

Seeing index.ts not found in my linter

I'm submitting a ... (check one with "x")

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior

file: 'file:///..../ui/node_modules/ngx-cookie/tsconfig.json'
severity: 'Error'
message: 'File '/.../ui/node_modules/ngx-cookie/index.ts' not found.'
at: '1,1'
source: 'ts'

Expected/desired behavior

Not to see this error. I suppose index.ts doesn't exist as defined tsconfig.json

Please tell us about your environment:

  • ngx-cookie version: 1.0.0

  • Angular version: 4.0.3

Error: No provider for CookieOptionsProvider! Jasmine unit testing

I'm submitting a ... (check one with "x")

[x ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
Can not use it while unit testing with jasmine.

Error: No provider for CookieOptionsProvider!

Expected/desired behavior

Reproduction of the problem
Inside a spec import the service
import { CookieService, CookieOptions } from 'ngx-cookie';
and provide it
.... providers: [ BaseRequestOptions, MockBackend, CookieService,

If I manually provide CookieOptionsProvider
import { COOKIE_OPTIONS, CookieOptionsProvider } from 'ngx-cookie/src/cookie-options-provider';

I get Error: No provider for Token COOKIE_OPTIONS!

Please tell us about your environment:

  • ngx-cookie version: 1.0.0

  • Angular version: 4.x.x

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Provide a CHANGELOG or fill in Releases on GitHub

I'm submitting a ... (check one with "x")

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior

There is no way to know what changes a new release brought, including what breaking changes have happened in 3.0.0 and what to do to adjust the code to be compatible with it.

Expected/desired behavior

There should be a CHANGELOG or GitHub Releases tab should be filled in with details.

Reproduction of the problem

N/A

What is the expected behavior?

Already described above.

What is the motivation / use case for changing the behavior?

Without the CHANGELOG it's hard to know what may break in a major update and what needs to be done to adjust to the breaking changes.

Please tell us about your environment:

  • ngx-cookie version: 2.0.1

  • Angular version: 5.2.9

  • Browser: all

How to create a session cookie?

Hi all!

A simple question: how can I set a session / transient cookie?
I omit the "expires" cookie option, but max-age property of the cookie is still set. How do I create a cookie without expiration date? I want it to be deleted automatically when the session ends.

Thanks in advance!

angular universal

document is not defined in angular universal

 protected get cookieString(): string {
    return document.cookie || '';
  }

see this

Option to not encode cookie values

I'm submitting a ... (check one with "x")

[ ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[x] feature request

Current behavior
Cookie value gets encoded when persisted.

Expected/desired behavior
Provide an option to not encode cookie value when persisting.

Reproduction of the problem
Try to store a cookie value of 'foo=bar' and it will be stored as 'Foo%3Dbar'

What is the motivation / use case for changing the behavior?
It is not possible to share the same cookie with legacy applications that do not encode cookie values

  • ngx-cookie version: 1.0.0

  • Angular version: 4.3.5

  • Browser: all

Not compatible with common.js module syntax

I'm submitting a ... (check one with "x")

[ ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[x] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
The package support ES6 module syntax which works perfectly fine when compiled using typescript loader, although when the package is used with Server-side Rendering Javascript Apps in which usually packages from node_modules are not compiled/transpiled, when running the app in Node.js runtime env, package is not compatible to use with common.js module syntax.

Expected/desired behavior
It should also be compatible with common.js module syntax.

Reproduction of the problem
If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar.

What is the expected behavior?
It should also be compatible with common.js module syntax.

What is the motivation / use case for changing the behavior?
To avoid transpiling the package when used with SSR apps running in Node env.

Please tell us about your environment:

  • ngx-cookie version: 1.0.0

  • Angular version: 4.3.x

  • Node.js: [6.11.x]

Does ngx-cookie support Angular 5?

Hi there,

Does ngx-cookie support Angular 5?

I get an issue when building it

node_modules/ngx-cookie/src/cookie-options-provider.d.ts(1,20): error TS2305: Module '"[home_path]/node_modules/@angular/core/core"' has no exported member 'OpaqueToken'.

Looks like OpaqueToken was replaced by InjectionToken. Please can you update the usage of this to use InjectionToken instead?

Stumped. Where is example on how to use "cookieoptions"

I'm submitting a ... (check one with "x")

[x ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

hi

Please posr an example on how to write a cookie with a session timeout using cookieoptions.

Thanks

StaticInjection on Parent Class

I'm submitting a ... (check one with "x")

[ ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ X] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
I have a superclass that needs the CookieService injected. I need to use StaticInjection, but when i declare the providers it says

TypeError: StaticInjectorError[e -> e]:
Cannot read property 'get' of undefined
at new e (ngx-cookie.umd.js:1)
at resolveToken (core.js:1296)
at tryResolveToken (core.js:1242)
at resolveToken (core.js:1288)
at tryResolveToken (core.js:1242)
at StaticInjector.get (core.js:1110)
at AppComponent.SessionComponent (session-component.component.ts:39)
at new AppComponent (app.component.ts:15)
at createClass (core.js:12439)
at createDirectiveInstance (core.js:12284)

The problem seams to be in the CookieOptionsProvider. I place it as Deps, but stil not working.

Please tell us about your environment:

  • ngx-cookie version: 3.0.1

  • Angular version: 5.2.9

  • Browser: [Chrome 64 ]

My code:

export let services = {

    'CookieOptionsProvider': {
        provide: CookieOptionsProvider,
        deps: []
      },
    
    'CookieService': {
      provide: CookieService,
      deps: [CookieOptionsProvider],
      useClass : CookieBackendService
    }
  }
  export class ServiceLocator {
    static injector: Injector;
  }
@NgModule({
    
})
export class SessionComponent {

    private cookieService  :CookieService;

    constructor() {
        this.cookieService = ServiceLocator.injector.get(CookieService);

Angular Universal Prerender - NullInjectorError: No provider for REQUEST!

I'm submitting a ... (check one with "x")

[ x ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
ERROR { Error: StaticInjectorError(AppServerModule)[REQUEST]:
StaticInjectorError(Platform: core)[REQUEST]:
NullInjectorError: No provider for REQUEST!
at NullInjector.get (.../dist/prerender.js:4898:19)

Expected/desired behavior
Successful build using prerender (npm run build:prerender)

  • ngx-cookie version: 4.0.2

  • Angular version: 6.1.0

  • Browser: Chrome Version 68.0.3440.106 (Official Build) (64-bit)

found version 4, expected 3

I npm install ngx-cookie --save, then npm run build, get this error:

Error: Metadata version mismatch for module
/Users/qiu/Downloads/fenbi_project/fenbi-wap/node_modules/ngx-cookie/dist/ngx-cookie.d.ts, found version 4,
expected 3
if I change the version from 4 to 3 in ngx-cookie.metadata.json ,can get the right result.

by the way , your last verion is 3.0.1

please fix this bug thanks

Cookies with same name, but different subdomains not handled properly

When a site has two cookies with the same name, but different domains (e.g. cookie1 domain = .company.com, cookie2 domain = .app1.company.com), the following line within the CookiesService results in the first cookie in the list returned by document.cookie always being selected.

if (isBlank((<any>lastCookies)[name])) {

The comment above that line of code...

          // the first value that is seen for a cookie is the most
          // specific one.  values for the same cookie name that
          // follow are for less specific paths.
          if (isBlank((<any>lastCookies)[name])) {
            (<any>lastCookies)[name] = safeDecodeURIComponent(cookie.substring(index + 1));
          }

... makes an invalid assumption. As per RFC6265 Section 4.2.2:

Although cookies are serialized linearly in the Cookie header,
servers SHOULD NOT rely upon the serialization order. In particular,
if the Cookie header contains two cookies with the same name (e.g.,
that were set with different Path or Domain attributes), servers
SHOULD NOT rely upon the order in which these cookies appear in the
header.

Certainly, on Chrome v66.0.3359.139, I've found that the assumption on Line 149 of CookiesService does not hold true. On Chrome, document.cookie provides the .company.com cookie before .app1.company.com.

The fact that this choice of order selection is hard-coded and hidden within this library can result in surprises to its users, like yours truly :).

On a side note, I've found this StackOverflow post to be helpful on this matter.

Since we must not rely on the cookie ordering, it would be best if this library makes it an explicit selection option that the user has to provide OR somehow determine the type of browser and do the right thing. I suspect the former is a saner and more maintainable approach.

Please note that I originally found this issue in the angular2-cookie library (see CookieService Line 130), which I now see has been deprecated. However, this same issue is also present in this new library. Therefore, I'm opening it here.

No provider for CookieService!

I'm submitting a ... (check one with "x")

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior

EXCEPTION: Uncaught (in promise): Error: DI Error
Error: DI Error
    at NoProviderError.ZoneAwareError (http://127.0.0.1:4200/polyfills.bundle.js:3527:33)
    at NoProviderError.BaseError [as constructor] (http://127.0.0.1:4200/vendor.bundle.js:30862:16)
    at NoProviderError.AbstractProviderError [as constructor] (http://127.0.0.1:4200/vendor.bundle.js:61336:16)
    at new NoProviderError (http://127.0.0.1:4200/vendor.bundle.js:61398:16)
    at ReflectiveInjector_._throwOrNull (http://127.0.0.1:4200/vendor.bundle.js:83888:19)
    at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:4200/vendor.bundle.js:83927:25)
    at ReflectiveInjector_._getByKey (http://127.0.0.1:4200/vendor.bundle.js:83859:25)
    at ReflectiveInjector_.get (http://127.0.0.1:4200/vendor.bundle.js:83728:21)
    at AppModuleInjector.get (/AppModule/module.ngfactory.js:264:124)
    at AppModuleInjector.getInternal (/AppModule/module.ngfactory.js:456:54)
    at AppModuleInjector.NgModuleInjector.get (http://127.0.0.1:4200/vendor.bundle.js:62271:44)
    at CompiledTemplate.proxyViewClass.AppView.injectorGet (http://127.0.0.1:4200/vendor.bundle.js:84663:45)
    at CompiledTemplate.proxyViewClass.DebugAppView.injectorGet (http://127.0.0.1:4200/vendor.bundle.js:85091:49)
    at ElementInjector.get (http://127.0.0.1:4200/vendor.bundle.js:84167:27)
    at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:4200/vendor.bundle.js:83924:24)
ErrorHandler.handleError @ error_handler.js:54
next @ application_ref.js:348
schedulerFn @ async.js:93
SafeSubscriber.__tryOrUnsub @ Subscriber.js:234
SafeSubscriber.next @ Subscriber.js:183
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ async.js:79
NgZone.triggerError @ ng_zone.js:333
onHandleError @ ng_zone.js:294
webpackJsonp.979.ZoneDelegate.handleError @ zone.js:334
webpackJsonp.979.Zone.runGuarded @ zone.js:142
_loop_1 @ zone.js:540
drainMicroTaskQueue @ zone.js:549
error_handler.js:59 ORIGINAL STACKTRACE:
ErrorHandler.handleError @ error_handler.js:59
next @ application_ref.js:348
schedulerFn @ async.js:93
SafeSubscriber.__tryOrUnsub @ Subscriber.js:234
SafeSubscriber.next @ Subscriber.js:183
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ async.js:79
NgZone.triggerError @ ng_zone.js:333
onHandleError @ ng_zone.js:294
webpackJsonp.979.ZoneDelegate.handleError @ zone.js:334
webpackJsonp.979.Zone.runGuarded @ zone.js:142
_loop_1 @ zone.js:540
drainMicroTaskQueue @ zone.js:549
error_handler.js:60 Error: Uncaught (in promise): Error: DI Error
Error: DI Error
    at NoProviderError.ZoneAwareError (zone.js:958)
    at NoProviderError.BaseError [as constructor] (errors.js:22)
    at NoProviderError.AbstractProviderError [as constructor] (reflective_errors.js:54)
    at new NoProviderError (reflective_errors.js:116)
    at ReflectiveInjector_._throwOrNull (reflective_injector.js:485)
    at ReflectiveInjector_._getByKeyDefault (reflective_injector.js:524)
    at ReflectiveInjector_._getByKey (reflective_injector.js:456)
    at ReflectiveInjector_.get (reflective_injector.js:325)
    at AppModuleInjector.get (module.ngfactory.js:264)
    at AppModuleInjector.getInternal (module.ngfactory.js:456)
    at AppModuleInjector.NgModuleInjector.get (ng_module_factory.js:139)
    at CompiledTemplate.proxyViewClass.AppView.injectorGet (view.js:152)
    at CompiledTemplate.proxyViewClass.DebugAppView.injectorGet (view.js:580)
    at ElementInjector.get (element_injector.js:32)
    at ReflectiveInjector_._getByKeyDefault (reflective_injector.js:521)
    at resolvePromise (zone.js:643) [angular]
    at resolvePromise (zone.js:619) [angular]
    at :4200/polyfills.bundle.js:3248:17 [angular]
    at Object.onInvokeTask (ng_zone.js:264) [angular]
    at ZoneDelegate.webpackJsonp.979.ZoneDelegate.invokeTask (zone.js:362) [angular]
    at Zone.webpackJsonp.979.Zone.runTask (zone.js:166) [<root> => angular]
    at drainMicroTaskQueue (zone.js:529) [<root>]
ErrorHandler.handleError @ error_handler.js:60
next @ application_ref.js:348
schedulerFn @ async.js:93
SafeSubscriber.__tryOrUnsub @ Subscriber.js:234
SafeSubscriber.next @ Subscriber.js:183
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ async.js:79
NgZone.triggerError @ ng_zone.js:333
onHandleError @ ng_zone.js:294
webpackJsonp.979.ZoneDelegate.handleError @ zone.js:334
webpackJsonp.979.Zone.runGuarded @ zone.js:142
_loop_1 @ zone.js:540
drainMicroTaskQueue @ zone.js:549
zone.js:516 Unhandled Promise rejection: No provider for CookieService! ; Zone: angular ; Task: Promise.then ; Value: NoProviderError {__zone_symbol__error: Error: DI Error
    at NoProviderError.ZoneAwareError (http://127.0.0.1:4200/polyfills.bundle.js:352…, _nativeError: ZoneAwareError, keys: Array[1], injectors: Array[1], __zone_symbol__message: "No provider for CookieService!"…}__zone_symbol__error: Error: DI Error
    at NoProviderError.ZoneAwareError (http://127.0.0.1:4200/polyfills.bundle.js:3527:33)
    at NoProviderError.BaseError [as constructor] (http://127.0.0.1:4200/vendor.bundle.js:30862:16)
    at NoProviderError.AbstractProviderError [as constructor] (http://127.0.0.1:4200/vendor.bundle.js:61336:16)
    at new NoProviderError (http://127.0.0.1:4200/vendor.bundle.js:61398:16)
    at ReflectiveInjector_._throwOrNull (http://127.0.0.1:4200/vendor.bundle.js:83888:19)
    at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:4200/vendor.bundle.js:83927:25)
    at ReflectiveInjector_._getByKey (http://127.0.0.1:4200/vendor.bundle.js:83859:25)
    at ReflectiveInjector_.get (http://127.0.0.1:4200/vendor.bundle.js:83728:21)
    at AppModuleInjector.get (/AppModule/module.ngfactory.js:264:124)
    at AppModuleInjector.getInternal (/AppModule/module.ngfactory.js:456:54)
    at AppModuleInjector.NgModuleInjector.get (http://127.0.0.1:4200/vendor.bundle.js:62271:44)
    at CompiledTemplate.proxyViewClass.AppView.injectorGet (http://127.0.0.1:4200/vendor.bundle.js:84663:45)
    at CompiledTemplate.proxyViewClass.DebugAppView.injectorGet (http://127.0.0.1:4200/vendor.bundle.js:85091:49)
    at ElementInjector.get (http://127.0.0.1:4200/vendor.bundle.js:84167:27)
    at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:4200/vendor.bundle.js:83924:24)__zone_symbol__message: "No provider for CookieService!"__zone_symbol__stack: "Error: DI Error↵    at NoProviderError.ZoneAwareError (http://127.0.0.1:4200/polyfills.bundle.js:3527:33)↵    at NoProviderError.BaseError [as constructor] (http://127.0.0.1:4200/vendor.bundle.js:30862:16)↵    at NoProviderError.AbstractProviderError [as constructor] (http://127.0.0.1:4200/vendor.bundle.js:61336:16)↵    at new NoProviderError (http://127.0.0.1:4200/vendor.bundle.js:61398:16)↵    at ReflectiveInjector_._throwOrNull (http://127.0.0.1:4200/vendor.bundle.js:83888:19)↵    at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:4200/vendor.bundle.js:83927:25)↵    at ReflectiveInjector_._getByKey (http://127.0.0.1:4200/vendor.bundle.js:83859:25)↵    at ReflectiveInjector_.get (http://127.0.0.1:4200/vendor.bundle.js:83728:21)↵    at AppModuleInjector.get (/AppModule/module.ngfactory.js:264:124)↵    at AppModuleInjector.getInternal (/AppModule/module.ngfactory.js:456:54)↵    at AppModuleInjector.NgModuleInjector.get (http://127.0.0.1:4200/vendor.bundle.js:62271:44)↵    at CompiledTemplate.proxyViewClass.AppView.injectorGet (http://127.0.0.1:4200/vendor.bundle.js:84663:45)↵    at CompiledTemplate.proxyViewClass.DebugAppView.injectorGet (http://127.0.0.1:4200/vendor.bundle.js:85091:49)↵    at ElementInjector.get (http://127.0.0.1:4200/vendor.bundle.js:84167:27)↵    at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:4200/vendor.bundle.js:83924:24)"_nativeError: ZoneAwareErrorconstructResolvingMessage: (keys)injectors: Array[1]keys: Array[1]message: (...)get message: ()set message: (value)name: (...)get name: ()set name: (value)originalStack: (...)get originalStack: ()set originalStack: (value)stack: (...)get stack: ()set stack: (value)toSource: ()toString: ()zoneAwareStack: (...)get zoneAwareStack: ()set zoneAwareStack: (value)__proto__: AbstractProviderError Error: DI Error
    at NoProviderError.ZoneAwareError (http://127.0.0.1:4200/polyfills.bundle.js:3527:33)
    at NoProviderError.BaseError [as constructor] (http://127.0.0.1:4200/vendor.bundle.js:30862:16)
    at NoProviderError.AbstractProviderError [as constructor] (http://127.0.0.1:4200/vendor.bundle.js:61336:16)
    at new NoProviderError (http://127.0.0.1:4200/vendor.bundle.js:61398:16)
    at ReflectiveInjector_._throwOrNull (http://127.0.0.1:4200/vendor.bundle.js:83888:19)
    at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:4200/vendor.bundle.js:83927:25)
    at ReflectiveInjector_._getByKey (http://127.0.0.1:4200/vendor.bundle.js:83859:25)
    at ReflectiveInjector_.get (http://127.0.0.1:4200/vendor.bundle.js:83728:21)
    at AppModuleInjector.get (/AppModule/module.ngfactory.js:264:124)
    at AppModuleInjector.getInternal (/AppModule/module.ngfactory.js:456:54)
    at AppModuleInjector.NgModuleInjector.get (http://127.0.0.1:4200/vendor.bundle.js:62271:44)
    at CompiledTemplate.proxyViewClass.AppView.injectorGet (http://127.0.0.1:4200/vendor.bundle.js:84663:45)
    at CompiledTemplate.proxyViewClass.DebugAppView.injectorGet (http://127.0.0.1:4200/vendor.bundle.js:85091:49)
    at ElementInjector.get (http://127.0.0.1:4200/vendor.bundle.js:84167:27)
    at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:4200/vendor.bundle.js:83924:24)
consoleError @ zone.js:516
_loop_1 @ zone.js:545
drainMicroTaskQueue @ zone.js:549
zone.js:518 ZoneAwareError {__zone_symbol__error: Error: Uncaught (in promise): Error: DI Error
Error: DI Error
    at NoProviderError.ZoneAwareError …, rejection: NoProviderError, promise: ZoneAwarePromise, zone: Zone, task: ZoneTask…}__zone_symbol__error: Error: Uncaught (in promise): Error: DI Error
Error: DI Error
    at NoProviderError.ZoneAwareError (http://127.0.0.1:4200/polyfills.bundle.js:3527:33)
    at NoProviderError.BaseError [as constructor] (http://127.0.0.1:4200/vendor.bundle.js:30862:16)
    at NoProviderError.AbstractProviderError [as constructor] (http://127.0.0.1:4200/vendor.bundle.js:61336:16)
    at new NoProviderError (http://127.0.0.1:4200/vendor.bundle.js:61398:16)
    at ReflectiveInjector_._throwOrNull (http://127.0.0.1:4200/vendor.bundle.js:83888:19)
    at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:4200/vendor.bundle.js:83927:25)
    at ReflectiveInjector_._getByKey (http://127.0.0.1:4200/vendor.bundle.js:83859:25)
    at ReflectiveInjector_.get (http://127.0.0.1:4200/vendor.bundle.js:83728:21)
    at AppModuleInjector.get (/AppModule/module.ngfactory.js:264:124)
    at AppModuleInjector.getInternal (/AppModule/module.ngfactory.js:456:54)
    at AppModuleInjector.NgModuleInjector.get (http://127.0.0.1:4200/vendor.bundle.js:62271:44)
    at CompiledTemplate.proxyViewClass.AppView.injectorGet (http://127.0.0.1:4200/vendor.bundle.js:84663:45)
    at CompiledTemplate.proxyViewClass.DebugAppView.injectorGet (http://127.0.0.1:4200/vendor.bundle.js:85091:49)
    at ElementInjector.get (http://127.0.0.1:4200/vendor.bundle.js:84167:27)
    at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:4200/vendor.bundle.js:83924:24)
    at NoProviderError.ZoneAwareError (http://127.0.0.1:4200/polyfills.bundle.js:3527:33)
    at NoProviderError.BaseError [as constructor] (http://127.0.0.1:4200/vendor.bundle.js:30862:16)
    at NoProviderError.AbstractProviderError [as constructor] (http://127.0.0.1:4200/vendor.bundle.js:61336:16)
    at new NoProviderError (http://127.0.0.1:4200/vendor.bundle.js:61398:16)
    at ReflectiveInjector_._throwOrNull (http://127.0.0.1:4200/vendor.bundle.js:83888:19)
    at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:4200/vendor.bundle.js:83927:25)
    at ReflectiveInjector_._getByKey (http://127.0.0.1:4200/vendor.bundle.js:83859:25)
    at ReflectiveInjector_.get (http://127.0.0.1:4200/vendor.bundle.js:83728:21)
    at AppModuleInjector.get (/AppModule/module.ngfactory.js:264:124)
    at AppModuleInjector.getInternal (/AppModule/module.ngfactory.js:456:54)
    at AppModuleInjector.NgModuleInjector.get (http://127.0.0.1:4200/vendor.bundle.js:62271:44)
    at CompiledTemplate.proxyViewClass.AppView.injectorGet (http://127.0.0.1:4200/vendor.bundle.js:84663:45)
    at CompiledTemplate.proxyViewClass.DebugAppView.injectorGet (http://127.0.0.1:4200/vendor.bundle.js:85091:49)
    at ElementInjector.get (http://127.0.0.1:4200/vendor.bundle.js:84167:27)
    at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:4200/vendor.bundle.js:83924:24)
    at resolvePromise (http://127.0.0.1:4200/polyfills.bundle.js:3212:31) [angular]
    at resolvePromise (http://127.0.0.1:4200/polyfills.bundle.js:3188:17) [angular]
    at http://127.0.0.1:4200/polyfills.bundle.js:3248:17 [angular]
    at Object.onInvokeTask (http://127.0.0.1:4200/vendor.bundle.js:32515:37) [angular]
    at ZoneDelegate.webpackJsonp.979.ZoneDelegate.invokeTask (http://127.0.0.1:4200/polyfills.bundle.js:2931:36) [angular]
    at Zone.webpackJsonp.979.Zone.runTask (http://127.0.0.1:4200/polyfills.bundle.js:2735:47) [<root> => angular]
    at drainMicroTaskQueue (http://127.0.0.1:4200/polyfills.bundle.js:3098:35) [<root>]__zone_symbol__message: "Uncaught (in promise): Error: DI Error↵Error: DI Error↵    at NoProviderError.ZoneAwareError (http://127.0.0.1:4200/polyfills.bundle.js:3527:33)↵    at NoProviderError.BaseError [as constructor] (http://127.0.0.1:4200/vendor.bundle.js:30862:16)↵    at NoProviderError.AbstractProviderError [as constructor] (http://127.0.0.1:4200/vendor.bundle.js:61336:16)↵    at new NoProviderError (http://127.0.0.1:4200/vendor.bundle.js:61398:16)↵    at ReflectiveInjector_._throwOrNull (http://127.0.0.1:4200/vendor.bundle.js:83888:19)↵    at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:4200/vendor.bundle.js:83927:25)↵    at ReflectiveInjector_._getByKey (http://127.0.0.1:4200/vendor.bundle.js:83859:25)↵    at ReflectiveInjector_.get (http://127.0.0.1:4200/vendor.bundle.js:83728:21)↵    at AppModuleInjector.get (/AppModule/module.ngfactory.js:264:124)↵    at AppModuleInjector.getInternal (/AppModule/module.ngfactory.js:456:54)↵    at AppModuleInjector.NgModuleInjector.get (http://127.0.0.1:4200/vendor.bundle.js:62271:44)↵    at CompiledTemplate.proxyViewClass.AppView.injectorGet (http://127.0.0.1:4200/vendor.bundle.js:84663:45)↵    at CompiledTemplate.proxyViewClass.DebugAppView.injectorGet (http://127.0.0.1:4200/vendor.bundle.js:85091:49)↵    at ElementInjector.get (http://127.0.0.1:4200/vendor.bundle.js:84167:27)↵    at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:4200/vendor.bundle.js:83924:24)"__zone_symbol__stack: "Error: Uncaught (in promise): Error: DI Error↵Error: DI Error↵    at NoProviderError.ZoneAwareError (http://127.0.0.1:4200/polyfills.bundle.js:3527:33)↵    at NoProviderError.BaseError [as constructor] (http://127.0.0.1:4200/vendor.bundle.js:30862:16)↵    at NoProviderError.AbstractProviderError [as constructor] (http://127.0.0.1:4200/vendor.bundle.js:61336:16)↵    at new NoProviderError (http://127.0.0.1:4200/vendor.bundle.js:61398:16)↵    at ReflectiveInjector_._throwOrNull (http://127.0.0.1:4200/vendor.bundle.js:83888:19)↵    at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:4200/vendor.bundle.js:83927:25)↵    at ReflectiveInjector_._getByKey (http://127.0.0.1:4200/vendor.bundle.js:83859:25)↵    at ReflectiveInjector_.get (http://127.0.0.1:4200/vendor.bundle.js:83728:21)↵    at AppModuleInjector.get (/AppModule/module.ngfactory.js:264:124)↵    at AppModuleInjector.getInternal (/AppModule/module.ngfactory.js:456:54)↵    at AppModuleInjector.NgModuleInjector.get (http://127.0.0.1:4200/vendor.bundle.js:62271:44)↵    at CompiledTemplate.proxyViewClass.AppView.injectorGet (http://127.0.0.1:4200/vendor.bundle.js:84663:45)↵    at CompiledTemplate.proxyViewClass.DebugAppView.injectorGet (http://127.0.0.1:4200/vendor.bundle.js:85091:49)↵    at ElementInjector.get (http://127.0.0.1:4200/vendor.bundle.js:84167:27)↵    at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:4200/vendor.bundle.js:83924:24)↵    at resolvePromise (http://127.0.0.1:4200/polyfills.bundle.js:3212:31) [angular]↵    at resolvePromise (http://127.0.0.1:4200/polyfills.bundle.js:3188:17) [angular]↵    at http://127.0.0.1:4200/polyfills.bundle.js:3248:17 [angular]↵    at Object.onInvokeTask (http://127.0.0.1:4200/vendor.bundle.js:32515:37) [angular]↵    at ZoneDelegate.webpackJsonp.979.ZoneDelegate.invokeTask (http://127.0.0.1:4200/polyfills.bundle.js:2931:36) [angular]↵    at Zone.webpackJsonp.979.Zone.runTask (http://127.0.0.1:4200/polyfills.bundle.js:2735:47) [<root> => angular]↵    at drainMicroTaskQueue (http://127.0.0.1:4200/polyfills.bundle.js:3098:35) [<root>]"message: (...)get message: ()set message: (value)name: (...)get name: ()set name: (value)originalStack: (...)get originalStack: ()set originalStack: (value)promise: ZoneAwarePromiserejection: NoProviderErrorstack: (...)get stack: ()set stack: (value)task: ZoneTasktoSource: ()toString: ()zone: ZonezoneAwareStack: (...)get zoneAwareStack: ()set zoneAwareStack: (value)__proto__: Object
consoleError @ zone.js:518
_loop_1 @ zone.js:545
drainMicroTaskQueue @ zone.js:549

Reproduction of the problem

It generates the cookie without errors, but the error happens when accessing the component Profile.

https://gist.github.com/YuriFontella/2d7580e43acad37cbf716d15b6bc3a11

Some type of route incompatibility?
I am using CookieService within a service.

What is the motivation / use case for changing the behavior?

I declare the CookieService provider everywhere possible

Please tell us about your environment:

  • ngx-cookie version: 1.0.0

  • Angular version: 2.4.9

  • Browser: [all]

Can not set Cookie domain or options

I'm submitting a ... (check one with "x")

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[x] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
Typically, the domain along with other options are optional to set when setting a new cookie. Tried different formats for the domain, as I am currently testing on a local server, and none is showing up in the developer console in chrome. The only time the cookie is present is when I do not give it options

Expected/desired behavior
I am not sure if there is something wrong with the options I am setting, but I don't think so.

Please tell us about your environment:

  • ngx-cookie version: 1.0.0

  • Angular version: 4.1.2

  • ** Ionic version:** 3.4.0

  • Browser: [ Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Replace deprecated OpaqueTokens with InjectionTokens<T>

I'm submitting a ...

[ ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[x] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
ngx-cookie use OpaqueToken which are deprecated since Angular v4.0.0.

Expected/desired behavior
Use InjectionToken instead which are the generically typed replacement.

What is the motivation / use case for changing the behavior?
Angular v5 will remove some of the deprecate from v4, containing OpaqueToken.
See Changelog 5.0.0-beta.6

Please tell us about your environment:

  • ngx-cookie version: 1.0.0

Client side cookies are missing on the server

I'm submitting a

[X] bug report => check the FAQ and search github for a similar issue or PR before submitting
[X] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
When I put() a cookie on client side, it does not appear on the server side.
On Chrome Network tab, I can see that all cookies are included the header.
If I append a cookie on the server (ASP.NET Core) then it is transferred to the client correctly. The opposite direction is problematic. Strangely, all other cookies are transferred, only the newly set cookies are missing (the ones I set on the client), while the browser persists them among sessions.

Expected/desired behavior
I'd like to have the all my cookies on the server side.

Please tell us about your environment:
ASP.NET Core 2.0, ngx-cookie v1.0.1 ( later I tried it with 2.0.1, no diff), Angulas 4, Angular Universal, Webpack, SSR,

  • ngx-cookie version: 1.0.1, and 2.0.1

  • Angular version: 4.2.5

  • Browser: Chrome 64

More info - boot.server.ts

import 'reflect-metadata';
import 'zone.js';
import 'rxjs/add/operator/first';
import { APP_BASE_HREF } from '@angular/common';
import { enableProdMode, ApplicationRef, NgZone, ValueProvider } from '@angular/core';
import { platformDynamicServer, PlatformState, INITIAL_CONFIG } from '@angular/platform-server';
import { createServerRenderer, RenderResult } from 'aspnet-prerendering';
import { AppModule } from './app/app.module.server';

enableProdMode();

export function convertDictToString(cookieDict: Array<{ key: string, value: string }>): string {
    let cookieString: string = '';
    for (let cookie of cookieDict) {
        cookieString += `${cookie.key}=${cookie.value}; `;
    }
    return cookieString;
}

export function getRequest(params: any) {
    const { cookie = [] as Array<{ key: string, value: string }> } = { cookie: params.data.cookies };
    const cookieString: string = convertDictToString(cookie);
    const req: any = {
        'headers': {
            'cookie': cookieString
        }
    };
    return req;
}

export function getResponse(params: any) {
    const { cookie = [] as Array<{ key: string, value: string }> } = { cookie: params.data.cookies };
    const cookieString: string = convertDictToString(cookie);
    const res: any = {
        'headers': {
            'cookie': cookieString
        }
    };
    return res;
}

export default createServerRenderer(params => {
    const req = getRequest(params);
    const res = getResponse(params);
    const providers = [
        { provide: INITIAL_CONFIG, useValue: { document: '<app></app>', url: params.url } },
        { provide: APP_BASE_HREF, useValue: params.baseUrl },
        { provide: 'BASE_URL', useValue: params.origin + params.baseUrl },
        { provide: 'REQUEST', useValue: req },
        { provide: 'RESPONSE', useValue: res }
    ];

    return platformDynamicServer(providers).bootstrapModule(AppModule).then(moduleRef => {
        const appRef: ApplicationRef = moduleRef.injector.get(ApplicationRef);
        const state = moduleRef.injector.get(PlatformState);
        const zone = moduleRef.injector.get(NgZone);

        return new Promise<RenderResult>((resolve, reject) => {
            zone.onError.subscribe((errorInfo: any) => reject(errorInfo));
            appRef.isStable.first(isStable => isStable).subscribe(() => {
                // Because 'onStable' fires before 'onError', we have to delay slightly before
                // completing the request in case there's an error to report
                setImmediate(() => {
                    resolve({
                        html: state.renderToString()
                    });
                    moduleRef.destroy();
                });
            });
        });
    });
});

Thanks

Error when building in Production Mode

ERROR in Metadata version mismatch for module C:/Users/MYAPP/node_modules/ngx-cookie/src/cookie-options.model.d.ts, found version 4, expected 3

"dependencies": { "@angular/animations": "^4.3.1", "@angular/common": "^4.3.1", "@angular/compiler": "^4.3.1", "@angular/compiler-cli": "4.2.5", "@angular/core": "^4.3.1", "@angular/forms": "^4.3.1", "@angular/http": "^4.3.1", "@angular/platform-browser": "^4.3.1", "@angular/platform-browser-dynamic": "^4.3.1", "@angular/platform-server": "4.2.5", "@angular/router": "^4.3.1", "@ngtools/webpack": "1.5.0", "@types/jquery": "^3.2.17", "@types/webpack-env": "1.13.0", "ag-grid": "^14.2.0", "ag-grid-angular": "^14.2.0", "angular-tree-component": "^7.0.1", "angular2-template-loader": "0.6.2", "aspnet-prerendering": "^3.0.1", "aspnet-webpack": "^2.0.1", "awesome-typescript-loader": "3.2.1", "bootstrap": "3.3.7", "css": "2.2.1", "css-loader": "0.28.4", "es6-shim": "0.35.3", "event-source-polyfill": "0.0.9", "expose-loader": "0.7.3", "extract-text-webpack-plugin": "2.1.2", "file-loader": "0.11.2", "html-loader": "0.4.5", "isomorphic-fetch": "2.2.1", "jquery": "3.2.1", "json-loader": "0.5.4", "preboot": "4.5.2", "raw-loader": "0.5.1", "reflect-metadata": "0.1.10", "rxjs": "5.4.2", "style-loader": "0.18.2", "to-string-loader": "1.1.5", "ts-mocks": "^0.2.2", "typescript": "^2.6.2", "url-loader": "0.5.9", "webpack": "2.5.1", "webpack-hot-middleware": "2.18.2", "webpack-merge": "4.1.0", "zone.js": "0.8.12" }

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.