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 AngularJS Basics (1.x) Improving Our Todo App Create a Custom Directive For β€œtodos”

Maximiliano Campos
Maximiliano Campos
1,080 Points

Error when i use the directive "<todo>"

When i use the directive <todo> i got this error: Error: [ng:areq] http://errors.angularjs.org/1.3.14/ng/areq?p0=mainCtrl&p1=not%20a%20function%2C%20got%20undefined

I have the code exactly equal that the video.

I believe the directive name is todos (with an 's').

1 Answer

Works for me. Looks like it's having trouble finding the controller and yes, the directive name should be plural in your index.html file: Does your todos.js look like:

angular.module('todoListApp') .directive('todos', function() { return { templateUrl: 'templates/todos.html', controller: 'mainCtrl' } })

Hope that helps.