salemdar / angular2-cookie

Implementation of Angular 1.x $cookies service to Angular 2
MIT License
109 stars 29 forks source link

No provider for CookieOptions! in angular2-cookie 1.2.4 #24

Closed willypuzzle closed 7 years ago

willypuzzle commented 7 years ago

My code compile clean but I got this "No provider for CookieOptions!" exception when I try to execute the code.

NOTE: I read the installation instruction but they seems to be for older version of Angular2 (before rc-5). I have followed the new Angular 2 way for providers addition (the way after rc-5). For instance:

import {CookieService} from 'angular2-cookie/core';

@NgModule({
  ....
  providers: [
      CookieService
  ]
})
salemdar commented 7 years ago

Hey @willypuzzle

The usage examples are actually intended for final releases. Could you show me your systemjs (or webpack) configuration?

Best regards, Samet

willypuzzle commented 7 years ago

I use this webpack https://github.com/AngularClass/angular2-webpack-starter I modified only the src

mattbrewer commented 7 years ago

I am having this same issue after upgrading to angular 2.1.0-rc.1

ModalSeoul commented 7 years ago

Same issue. Any update on this?

NishantDesai1306 commented 7 years ago

This will get rid of the exception 'No provider for CookieOptions' Add CookieOptions in your import statement like import { CookieService, CookieOptions } from 'angular2-cookie'; and then add both CookieService and CookieOptions in your Root Module's provider array.

But after doing this i get another exception Can't resolve all parameters for CookieOptions: (?). can anyone help in regarding this issue.

salemdar commented 7 years ago

I have just updated the version to 1.2.5. All tests pass with angular 2.1.0.

trsh commented 7 years ago

I'm still getting this error in 1.2.5! Using https://github.com/AngularClass/angular2-webpack-starter

trsh commented 7 years ago

In vendors

// angular2 cookie
import 'angular2-cookie/core'

module

import { CookieService } from 'angular2-cookie/core';

providers: [
    xx,
    CookieService
  ]

component

import { CookieService } from 'angular2-cookie/core';

constructor(
    private fb: FormBuilder,
    private xx: xxxx,
    private cookieService: CookieService
  ) {
    super();
  }
trsh commented 7 years ago

@salemdar can u look into it?

ranglang commented 7 years ago

same error

rafaelss95 commented 7 years ago

I'm facing this problem with the latest version. By the way, I'm using with angular2-webpack.

dahoba commented 7 years ago

1.2.5 is working! if I upgrade my project to angular 2.2.0 (

app.module.js:

...
import { CookieService } from 'angular2-cookie/core';
...
@NgModule({
...
  providers: [
    CookieService
  ],
  bootstrap: [AppComponent]
})
...

vendor.ts:

...
import 'angular2-cookie/core';
...

custom.service.js:

...
import { CookieService } from 'angular2-cookie/core';
...
constructor(private cookieService:CookieService) {
}
...
trsh commented 7 years ago

I'm using 2.2.1, and it's not.

bigggge commented 7 years ago

I'm still getting this error in 1.2.5 ,angular 2.2.0 and webpack 2.1.0-beta.25

brendanalexdr commented 7 years ago

I am using angular-cli (1.0.0-beta.24) with angular2-cookie(1.2.6) and am getting this error only when I do an AOT build.

ng serve --> this works ng serve -prod -->this works ng serve -aot -->this does NOT work: Error: No provider for CookieOptions! ng serve -prod -aot -->this does NOT work: Error: No provider for CookieOptions!

CobusKruger commented 7 years ago

For me, this error was because I had neglected to import the CookieModule.

lincolnthree commented 7 years ago

There is no CookieModule

shashouzhiwang commented 6 years ago

same error

jlam55555 commented 6 years ago

This worked for me.

igormap42 commented 6 years ago

I have the same issue as @nukuuk. I saw @salemdar uploaded a new version along time ago in another branch on gitHub, but for some reason I don't see it in NPM, so I can't use it. For now I just forced to use another package for cookies.

jlam55555 commented 6 years ago

@igormap42 Did you try what I linked? It worked for me (and it seems to have worked for many people on that thread).