Seemingly random "Uncaught SyntaxError: Unexpected token . "


#1

I sometimes get this error: "Uncaught SyntaxError: Unexpected token . " My app.js is here: http://pastebin.com/k8Tpympu. My index.html is here: http://pastebin.com/y2Udw9G7.

The issue seems to be randomly occurring. For instance, this same code was running. What I did to make the code break was to remove localStorageService from the controller definition and on reload, the code broke. I have replaced the localStorageService in the controller definition but still the code breaks.

The error in the browser console is:

Uncaught SyntaxError: Unexpected token .
Uncaught Error: [$injector:modulerr] http://docs.angularjs.org/error/$injector/modulerr?p0=lukaduka-pos&p1=Error:%20[$injector:nomod]%20http:%2F%2Ferrors.angularjs.org%2F1.2.12%2F$injector%2Fnomod%3Fp0%3Dlukaduka-pos %20%20%20%20)

I am a bit baffled by the Uncaught Error complaint. As you can see from the pastebin, the module definition looks fine.

Anyone with some insights? I am stumped.

Thanks
Nii Amon


#2

Following along the links in the error report, I landed on this page: http://docs.angularjs.org/error/$injector/nomod?p0=lukaduka-pos.

The root of the problem is this:
“Module ‘lukaduka-pos’ is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.”

This is my module registration:

angular.module(‘lukaduka-pos’, [‘ionic’, ‘LocalStorageModule’]);

This looks ok to me. Can anyone spot anything wrong here?


#3

Weirder and weirder. I got the code to work now.

What I did was to delete my app.js code and copy and paste the last version of the app.js code from the tutorial. I then edited it to look exactly like my code which wasn’t working. The gist for the new code which is working can be found here: https://gist.github.com/niiamon/9500a4d208ed3ca569c2. It’s essentially the same as my code which wasn’t working here: http://pastebin.com/k8Tpympu.

Can anyone spot the differences? I can’t see any significant differences.


#4

The issue is the ; on your very first line angular.module('lukaduka-pos', ['ionic', 'LocalStorageModule']);.


#5

Thanks buddy. Got that fixed!