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

james rochabrun
PLUS
james rochabrun
Courses Plus Student 22,726 Points

Built in directives in angular JS

Hi, i have a problem setting my directives in one file and the controllers in other, as far as i understand , in this example 'myApp' is the main app and in it array i need to put all the dependencies suchs as ngMaterial etc, and also the 'itemDirective' so i can call those directives right?

Btw, i also put both script files in my html, i dont know what could be wrong, thank you!

app.js
(function() {

var app = angular.module('myApp', ['itemDirective','ngMaterial', 'ngMessages', 'ngTouch', 'ngAnimate']);
//controllers
  });
 })();
directives.js
(function() {

var app = angular.module('itemDirective', []);
    app.directive('item', function(){
    return {
      templateUrl: 'template.html',
      restrict: 'A'
    }
  });
 })();
akak
akak
29,445 Points

What is the order of files in your HTML? What error do you get?