Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialHeatherdawn Wadleigh
12,301 Pointsapp.js errors
My app.js file so far:
angular.module("todoListApp", [])
.controller('mainCtrl', function($scope) {
$scope.helloWorld = function() {
console.log("Console message");
};
});
My JSLint feedback:
1 Undeclared 'angular'.
angular.module("todoListApp", []) // Line 1, Pos 1
2 Expected '.' at column 5, not column 1.
.controller('mainCtrl', function($scope) { // Line 2, Pos 1
3 Expected one space between 'function' and '('.
.controller('mainCtrl', function($scope) { // Line 2, Pos 33
4 Expected 'use strict' before '$scope'.
$scope.helloWorld = function() { // Line 3, Pos 3
5 Expected one space between 'function' and '('.
$scope.helloWorld = function() { // Line 3, Pos 31
6 Expected 'console' at column 13, not column 5.
console.log("Console message"); // Line 4, Pos 5
7 Expected '}' at column 9, not column 3.
}; // Line 5, Pos 3
8 Expected '}' at column 5, not column 1.
}); // Line 6, Pos 1
My Markup:
<div ng-controller="mainCtrl" class="list">
<input type="checkbox">
<label class="editing-label">Sample ToDo</label>
<input class="editing-label" type="text">
<div class="actions">
<a class="button" href="#!">edit</a>
<a class="button" href="#!" ng-click="helloWorld()">save</a>
<a class="button delete" href="#!">delete</a>
</div>
</div><!-- /mainCtrl -->
4 Answers
jared eiseman
29,023 PointsTwo questions: A) Do you have your ng-app directive in your markup? B) Do you have the necessary angular script includes? (E.G. angular.min.js). Also, if I'm not mistaken JSLint requires things like angular and jquery to be declared as global variables under options if you're just trying to clear the warnings.
Heatherdawn Wadleigh
12,301 PointsHi Jared,
Thanks for your reply. I do have the ng-app directive attached to the body tag. And I'm loading a minified version of angular.js in the footer (I'm combining angular.js + app.js into a minified app.min.js file). And I think I get what you're saying about the JHLint warnings (not really crucial here?)
jared eiseman
29,023 PointsAre you getting any errors in the console and/or is the app not working, or are you just having lint check it out for you and are concerned about the warnings?
Heatherdawn Wadleigh
12,301 PointsThis is my best attempt to paste what was in my console:
Error: [$injector:unpr] Unknown provider: eProvider <- e <- mainCtrl http://errors.angularjs.org/1.4.4/$injector/unpr?p0=eProvider%20%3C-%20e%20%3C-%20mainCtrl at angular.js:68 at angular.js:4284 at Object.r [as get] (angular.js:4432) at angular.js:4289 at r (angular.js:4432) at Object.i [as invoke] (angular.js:4464) at f.instance (angular.js:9093) at m (angular.js:8205) at s (angular.js:7637) at s (angular.js:7641)
jared eiseman
29,023 Pointscan you copy how you have the ng-app directive declared in your body tag? Better yet, your entire html file. Copying and pasting your exact code into the workspace for this video is working for me fine.
Heatherdawn Wadleigh
12,301 PointsOK, I did see some errors in my markup, and now it's working. Thanks for your help, that made me focus on the real problem, and find it. Cheers!
jared eiseman
29,023 PointsNo problem, glad to help. Happy coding!