I keep running into Uncaught SyntaxError: Unexpected token
errors, but I can't see where I'm missing/have an extra ;
or )
character. It gives me a line in the code (see below), but it appears to be a valid token placement.
JSLint gives me some clarification: Expected ')' to match '(' from line 2 and instead saw ';'.
Below is the JavaScript code I'm writing (inner sections removed for brevity):
'use strict';
(function() {
AppCtrl = function($scope) {
//JSON data
};
window.AppCtrl = AppCtrl;
}; //Error shows up on this line
// Declare app level module which depends on views and components
angular.module('careApp', [
//Dependencies
])
.config(['$routeProvider', function($routeProvider) {
//if given invalid partial, go back to appLaunch.html
$routeProvider.otherwise({
redirectTo: '/appLaunch'
});
}])
.controller('AppCtrl', ['$scope', window.AppCtrl]);
var patientID = ''; $scope.idStore = function() {
//stuff
}
$scope.patientTime = function() {
//more stuff
}
})();
};
is ending your function: so its basically(function(){};
which is invalid syntax because you cannot have multiple statements inside()
. You already closed offAppCtrl
above thewindow.AppCtrl =
line – Patrick Evans Mar 10 at 20:59window.AppCtrl = AppCtrl
. You've already closed off theAppCtrl
function and now you're trying to close something else. – Mike C Mar 10 at 21:05AppCtrl
. Put avar
in front ofAppCtrl
. (var AppCtrl = ...
) – Mike C Mar 10 at 21:14