Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!"
  };
});