Checking for cookie: SyntaxError: Unexpected token u - angularjs

I'm trying to see whether a cookie key is set:
if ($cookieStore.get('user')){
$scope.session.user = $cookieStore.get('user');
console.log($scope.session.user);
}
An I get the error on the first line. This looks simple, so what am I doing wrong?
Full error:
SyntaxError: Unexpected token u
at Object.parse (native)
at Object.fromJson (http://localhost:8000/vendor/angular/angular.js:1139:14)
at Object.get (http://localhost:8000/vendor/angular/angular-cookies/angular-cookies.js:172:34)
at new <anonymous> (http://localhost:8000/js/main.js:44:33)
at invoke (http://localhost:8000/vendor/angular/angular.js:3966:17)
at Object.instantiate (http://localhost:8000/vendor/angular/angular.js:3977:23)
at http://localhost:8000/vendor/angular/angular.js:7281:28
at http://localhost:8000/vendor/angular/angular.js:6670:34
at forEach (http://localhost:8000/vendor/angular/angular.js:332:20)
at nodeLinkFn (http://localhost:8000/vendor/angular/angular.js:6657:11)

This was asked a year ago, but I just got the same error today.
All I did to resolve this was basically to clear my browser's cookies, and the error went away.

Related

My react app gives an error for some reason

Error:
src\images\navbar.js
Line 2:11: Parsing error: Unexpected token, expected "from" (2:11)
src\navbar.js
Line 2:11: Parsing error: Unexpected token, expected "from" (2:11)
the project on GitHub: https://github.com/PufflyMan/airbnb-exp-clone
It's pretty straightforward code but no matter what I tried, I couldn't fix it. Thanks for attention!
It just fixed itself. I didn't do anything

Hard to trace real root cause under chrome dev tools

I've changed dozens of controllers, services, and html
And got an Unknown provider exception
Unknown provider: bankServiceProvider <- bankService <- BanksBaseCtrl
However, it didn't tell me this is due to which file.
The debug message on chrome console is helpless.
Is there any useful way to trace the buggy source file?
Thanks so much
angular.js:12477 Error: [$injector:unpr] Unknown provider: bankServiceProvider <- bankService <- BanksBaseCtrl
http://errors.angularjs.org/1.4.7/$injector/unpr?p0=bankServiceProvider%20%3C-%20bankService%20%3C-%20BanksBaseCtrl
at http://dev.co/libs/angular/angular/angular.js:68:12
at http://dev.co/libs/angular/angular/angular.js:4289:19
at Object.getService [as get] (http://dev.co/libs/angular/angular/angular.js:4437:39)
at http://dev.co/libs/angular/angular/angular.js:4294:45
at getService (http://dev.co/libs/angular/angular/angular.js:4437:39)
at Object.invoke (http://dev.co/libs/angular/angular/angular.js:4469:13)
at extend.instance (http://dev.co/libs/angular/angular/angular.js:9136:34)
at nodeLinkFn (http://dev.co/libs/angular/angular/angular.js:8248:36)
at compositeLinkFn (http://dev.co/libs/angular/angular/angular.js:7680:13)
at publicLinkFn (http://dev.co/libs/angular/angular/angular.js:7555:30) <div ui-view="" class="fade-in ng-scope">

It means you injected bankService into BanksBaseCtrl and angular couldn't resolve bankService.
Verify that you properly registered bankService (with that exact name) with the angular module:
angular.module('yourapp').service('bankService',function(){...});
or, alternatively, correct the injected service name within BanksBaseCtrl.

Angular and Jade unexpected token error

New to Jade, trying to figure it out. I keep getting a wonky error saying:
Uncaught SyntaxError: Unexpected token <
angular.js:1 Uncaught SyntaxError: Unexpected token <
angular-resource.js:1 Uncaught SyntaxError: Unexpected token <
angular-route.js:1 Uncaught SyntaxError: Unexpected token <
app.js:1 Uncaught SyntaxError: Unexpected token <
I'm wondering if there's an issue grabbing my files/scripts? In the scripts.jade file, it looks like this:
script(type="text/javascript", src="multivision/vendor/jquery/jquery.js")
script(type="text/javascript", src="multivision/vendor/angular/angular.js")
script(type="text/javascript", src="multivision/vendor/angular- resource/angular-resource.js")
script(type="text/javascript", src="multivision/vendor/angular- route/angular-route.js")
script(type="text/javascript", src="multivision/app/app.js")
Thoughts?

Error: [$injector:unpr] http://errors.angularjs.org/1.3.4/$injector/unpr?p0=%24ngMapProvider%20%3C-%20%24ngMap at Error (native)

I get following error when I run my application. Just want to know what this means if anyone has experienced with the same?
Error: [$injector:unpr] http://errors.angularjs.org/1.3.4/$injector/unpr?p0=%24ngMapProvider%20%3C-%20%24ngMap
at Error (native)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.min.js:6:416
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.min.js:38:22
at Object.d [as get] (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.min.js:36:49)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.min.js:38:94
at d (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.min.js:36:49)
at e (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.min.js:36:310)
at Object.instantiate (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.min.js:36:451)
at $get (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.min.js:75:409)
at http://localhost:11080/angularui/ui-bootstrap-tpls-0.12.0.min.js:8:29473
NOTE: Code is bit complex to publish here.
You're trying to inject/use ngMapProvider in a place where it isn't correctly included as a dependency.
See: https://docs.angularjs.org/error/$injector/unpr

Unsure what Unknown Provider: $attrsProvider <- $attrs means?

I am encountering the following error when I run my Karma Unit Tests:
Error: [$injector:unpr] Unknown provider: $attrsProvider <- $attrs
http://errors.angularjs.org/1.2.16/$injector/unpr?p0=%24attrsProvider%20%3C-%20%24attrs
at /home/ubuntu/vantage/core/static/core/js/lib/angular.js:78:12
at /home/ubuntu/vantage/core/static/core/js/lib/angular.js:3705:19
at Object.getService [as get] (/home/ubuntu/vantage/core/static/core/js/lib/angular.js:3832:39)
at /home/ubuntu/vantage/core/static/core/js/lib/angular.js:3710:45
at getService (/home/ubuntu/vantage/core/static/core/js/lib/angular.js:3832:39)
at invoke (/home/ubuntu/vantage/core/static/core/js/lib/angular.js:3859:13)
at Object.instantiate (/home/ubuntu/vantage/core/static/core/js/lib/angular.js:3880:23)
at /home/ubuntu/vantage/core/static/core/js/lib/angular.js:7134:28
at null.<anonymous> (/home/ubuntu/vantage/ecommerce/js_tests/unit/progress/progressControllersSpec.js:12:20)
at Object.invoke (/home/ubuntu/vantage/core/static/core/js/lib/angular.js:3869:17)
Error: Declaration Location
at window.inject.angular.mock.inject (/home/ubuntu/vantage/core/static/core/js/lib/angular-mocks.js:2132:25)
at null.<anonymous> (/home/ubuntu/vantage/ecommerce/js_tests/unit/progress/progressControllersSpec.js:10:20)
at null.<anonymous> (/home/ubuntu/vantage/ecommerce/js_tests/unit/progress/progressControllersSpec.js:5:5)
at /home/ubuntu/vantage/ecommerce/js_tests/unit/progress/progressControllersSpec.js:3:1
TypeError: Cannot call method 'expectGET' of undefined
at null.<anonymous> (/home/ubuntu/vantage/ecommerce/js_tests/unit/progress/progressControllersSpec.js:380:18)
Chrome 33.0.1750 (Linux): Executed 42 of 45 (1 FAILED) (0 secs / 0.483 secs)
Chrome 33.0.1750 (Linux) Unit Test: ProgressController ProgressController should expect showDetailedSection to be false on initialization FAILED
Error: [$injector:unpr] Unknown provider: $attrsProvider <- $attrs
Anyone know what this means exactly and how to fix it?
Thanks :)
The solution to this ended up being pretty obscure.
The issue was that the bootstrap-ui package actually has a ProgressController in it. So our controller got stomped on. The test was trying to create an instance of our ProgressController but ended up with the one from bootstrap-ui.
Simply renaming our controller fixed everything.

Resources