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

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?