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) Getting Started with Angular Your First Angular Directive

Shanita Scott
Shanita Scott
1,095 Points

I have typed in everything that the teacher did in the video but it is not injecting my custom directive. Please help!

Here is my code: HTML <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <link href="https://fonts.googleapis.com/css?family=Varela+Round" rel="stylesheet" type="text/css"> <link href="styles/main.css"rel="stylesheet" type="text/css"> </head> <body ng-app="todoListApp"> <div hello-world></div>

<script src="vendor/angular.js"></script> <script src="scripts/app.js"></script> <script src="scripts/hello-world.js"></script>

</body> </html>

App.js

var app = angular.module('todoListApp', []);

hello-world.js

var app = angular.module('todoListApp'); app.directive('helloWorld', function(){ return { template: "This is my hello world directive!" }; });

1 Answer

Ryan Cates
Ryan Cates
18,344 Points
angular.module('todoListApp')
.directive('helloWorld', function() {
  return {
    template: "This is my hello world directive!"
  };
});