Closed phil123456 closed 7 years ago
anyone ?
This way, you would have to import angular2-cookie/core
at some point before bootstrapping.
However, the proper way to do this would be to create a CookieModule
and just import that. You could try and join forces on #37, it will solve your problem too.
I am quiet new to angular, what do you mean adding it to a module ?
Create a @NgModule
https://angular.io/docs/ts/latest/guide/ngmodule.html and let it provide the CookieService
.
but my main comopnent is already a module
so you mean like this ?
import 'angular2-cookie/core';
import { CookieService } from 'angular2-cookie/services/cookies.service';
in chrome, I get these errors
GET http://localhost:3000/angular2-cookie/core 404 (Not Found) GET http://localhost:3000/angular2-cookie/services/cookies.service 404 (Not Found)
for some reason, node-modules is not added to the path ...wtf ???
even weirder, if I add it to the path, I still get a 404
what am I missing ???
{
"name": "angular-quickstart",
"version": "1.0.0",
"description": "QuickStart package.json from the documentation, supplemented with testing support",
"scripts": {
"build": "tsc -p src/",
"build:watch": "tsc -p src/ -w",
"build:e2e": "tsc -p e2e/",
"serve": "lite-server -c=bs-config.json",
"serve:e2e": "lite-server -c=bs-config.e2e.json",
"prestart": "npm run build",
"start": "concurrently \"npm run build:watch\" \"npm run serve\"",
"pree2e": "npm run build:e2e",
"e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
"preprotractor": "webdriver-manager update",
"protractor": "protractor protractor.config.js",
"pretest": "npm run build",
"test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
"pretest:once": "npm run build",
"test:once": "karma start karma.conf.js --single-run",
"lint": "tslint ./src/**/*.ts -t verbose"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"@angular/common": "~2.4.0",
"@angular/compiler": "~2.4.0",
"@angular/core": "~2.4.0",
"@angular/forms": "~2.4.0",
"@angular/http": "~2.4.0",
"@angular/platform-browser": "~2.4.0",
"@angular/platform-browser-dynamic": "~2.4.0",
"@angular/router": "~3.4.0",
"angular-in-memory-web-api": "~0.2.4",
"angular2-cookie": "^1.2.4",
"core-js": "^2.4.1",
"rxjs": "5.0.1",
"systemjs": "0.19.40",
"zone.js": "^0.7.4"
},
"devDependencies": {
"concurrently": "^3.2.0",
"lite-server": "^2.2.2",
"typescript": "~2.0.10",
"canonical-path": "0.0.2",
"tslint": "^3.15.1",
"lodash": "^4.16.4",
"jasmine-core": "~2.4.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~4.0.14",
"rimraf": "^2.5.4",
"@types/node": "^6.0.46",
"@types/jasmine": "2.5.36"
},
"repository": {}
}
I noticed that when it happened for other components/modules it's mainly becos of coding errors, so I believe this cookie lib is not compatible with angular 2.4.0, guess I'll have to use the setcookie function from javascript :-(
It is compatible actually. But I am refactoring it a little bit at the moment to work smoother. Expect an update on weekend.
Btw, you should import it like this:
import { CookieService } from 'angular2-cookie/core';
It is in the docs.
GET http://localhost:3000/angular2-cookie/core 404 (Not Found)
Then you are not configuring your systemjs properly.
??? it's a seed I downloaded https://github.com/angular/quickstart
I have uploaded that seed (it's the OFFICIAL angular 2 seed from the tutorials)
just adding the angular2-cookies lib in it
http://176.31.233.212/test.zip
can someone check it and make it work ?
thanks
Have you configured the systemjs? Please read the getting started part of this library carefully.
yes, please check the archive, it wont bite ;-)
You haven't even touch systemjs.config.js
and systemjs.config.extras.js
. The configuration is literally here in the documentation.
finaly I could make it work, found out I was modifying the wrong file which was also the explanation for this one
https://github.com/salemdar/angular2-cookie/issues/49#issuecomment-283597252
if only it had been answered instead of just beeing blindly closed
thx anyway :-)
I cannot load the cookie service
in chrome I get an error that looks like a json
Object { __zone_symbol__error: Error, fileName: Getter, lineNumber: Getter, columnNumber: Getter, message: Getter, name: Getter, stack: Getter, originalStack: Getter, zoneAwareStack: Getter, toString: createMethodProperty/props[key].value(), 3 de plus… }
I installed angular2-cookie with npm
here is the code of my app
the error appears, just by adding the providers array