I just started learning Javascript and AngularJS and have a decent Java and C++ background.
Today I wasted an entire day debugging a trivial error that boiled down to a missing comma in a JSON file: "name": "Melbourne",
"snippet": "Melbourne"
"location":{"lat": "37.8136S", "long": "144.9631E"}
Now I'm wondering: What's the Javascript/AngularJS way of debugging? - for this specific case as well as in general. Spending 8 hours changing every line in the code can't be the solution. In C++/Java I would look at the stacktrace so i checked the chrome console output and found:
SyntaxError: Unexpected string
at Object.parse (native)
at fromJson (http://localhost:8000/app/bower_components/angular/angular.js:1078:14)
at $HttpProvider.defaults.defaults.transformResponse (http://localhost:8000/app/bower_components/angular/angular.js:7317:18)
at http://localhost:8000/app/bower_components/angular/angular.js:7292:12
at Array.forEach (native)
at forEach (http://localhost:8000/app/bower_components/angular/angular.js:323:11)
at transformData (http://localhost:8000/app/bower_components/angular/angular.js:7291:3)
at transformResponse (http://localhost:8000/app/bower_components/angular/angular.js:7963:17)
at wrappedCallback (http://localhost:8000/app/bower_components/angular/angular.js:11319:81)
at http://localhost:8000/app/bower_components/angular/angular.js:11405:26 angular.js:9778
How is this supposed to help me? I see nothing that even remotely tells me to check my JSON or my code - only library code. The offending lines in my code are
//citycontroller.js
$scope.cities= City.query();
//cityservice.js
cityServices.factory('City', ['$resource',
function($resource){
return $resource('cities/:cityId.json', {}, {
query: {method:'GET', params:{cityId:'cities'}, isArray:true}
});
}]);
Why isn't there a stacktrace for either of these lines?