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 trial

JavaScript

Angular JS Controller: I'm getting two errors, one of them very weird: Uncaught Error: [$injector:modulerr]

I'm running the project on a local host in my computer with WAMP, but I'm running into two errors:

  1. Uncaught SyntaxError: Unexpected token {
  2. Uncaught Error: [$injector:modulerr]

Below, I'm pasting my codes.

  1. app.js

angular.module("todoListApp", []) .controller('mainCtrl', function($scope) { $scope.helloWorld = fucntion() { console.log("oi"); }; });

  1. HTML (just the body tag):

<body ng-app="todoListApp"> <h1>My ToDos</h1>

<section ng-controller-"mainCtrl" class="list"> <input type="checkbox" name="" value="" /> <label for="" class="editing-label">A sample to do!</label> <input type="text" class="editing-label" name="" value=""> <section class="actions"> <a href="">edit</a> <a href="" ng-click="helloWorld()">save</a> <a href="" class="delete">delete</a> </section> </section>

<!-- <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script> --> <script src="vendor/angular.min.js" type="text/javascript"></script> <script src="scripts/app.js" type="text/javascript"></script> </body>

Does anyone knows how to fiz those errors?

Thanks a lot!

1 Answer

You have a typo in app.js at $scope.helloWorld = fucntion(). Try correcting fucntion() to function(). Let's hope it solves your problems.