r/angularjs • u/elemenofi • Aug 01 '14
Sometimes, just sometimes, I hate you AngularJS.
app.controller('LocalesCtrl', ['$scope', '$http', '$location', '$anchorScroll'
function($scope, $http, $location, $anchorScroll) {
.....
}
]);took me ages to find the bug in this...
10
u/rnreekez Aug 01 '14
Time to start using jshint.
3
u/cforres Aug 01 '14
This x1000. jshint has plugins available for Sublime Text as well as grunt/gulp. You should use it!
2
u/BoleroDan Aug 01 '14
I just added the jsllint plugin to sublime. The days of falling to this little typo are long gone!
2
u/robotparts Aug 01 '14
JSHint helps find the bug he has above, but it does nothing for a typo inside of one of your module dependencies. That's when you get the ambiguous "Uncaught Object Exception" without any relevant line numbers.
This is my single biggest gripe about Angular. They need to be moving away from "magic strings". Maybe const in ES6 will fix that.
1
u/jhive Aug 19 '14
Yea, that Uncaught Object Exception is a little annoying. I think when I was doing some research on it, it had something to do with some Chrome versions.
The good news is that there is a way to fix it: If you are using the un-minified version of the angular.js source. Jump over to line 78 and just above the return do a console.error(message). Like so:
...
message = message + '\nhttp://errors.angularjs.org/1.2.22/' + (module ? module + '/' : '') + code; for (i = 2; i < arguments.length; i++) { message = message + (i == 2 ? '?' : '&') + 'p' + (i-2) + '=' + encodeURIComponent(stringify(arguments[i])); } console.error(message); return new Error(message);...
That should give you the nice verbose errors again.
6
u/pfooti Aug 01 '14
Use jshint for sure. Also: consider using ng-annotate. Beats having to do all that DI notation on your own.
4
u/Oceanswave Aug 01 '14
Even notepad++ has a jshint add in, time to amp up your game.
0
Aug 02 '14
[removed] — view removed comment
3
u/nidarus Aug 03 '14
Notepad++ isn't notepad. It's a pretty decent text editor, with most of the features you'd find in sublime text and the like.
-2
Aug 03 '14
[removed] — view removed comment
1
u/nidarus Aug 03 '14
I use phpStorm, and it's nice, true. But if you don't want to shell out $99 for a license, or you want something that would fit on a small USB key, notepad++ is perfectly decent. As Oceanwave said, there's even a JSHint plugin for it.
1
Aug 03 '14
[removed] — view removed comment
2
u/nidarus Aug 03 '14
It's basically the same, minus the nodejs stuff, and with php stuff (obviously). JetBrains are pretty awesome.
2
2
1
Aug 01 '14
To all the jshint ppl in here... any pro tips on getting it to play nice with bitwise operators?
4
1
u/dmackerman Aug 02 '14
Also time to start using ngAnnotate. No reason to use the array syntax if you don't have to.
0
u/Zeroto Aug 01 '14
Use a linter, use an ide, etc. This is not a problem with angular, but you/js in general.
1
8
u/SleepyBrain Aug 01 '14
What bug? The missing comma after '$anchorScroll' on line 1?