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

Nick Marsh
Nick Marsh
14,763 Points

Angular Stage 4 Challenge 2

I can't seem to get this one right. Any help would be much appreciated.

angular.module('myApp', [])
  .directive('treehouseCourse', function () {
    return {
      link: function ($scope, $element, $attrs) {

        $element.treehouseCourse({
          console.log($attrs.course-title);
          });
      }
    }
  });

6 Answers

Hey bro,

The '$element.treehouseCourse({' and '});' part is unnecessary.

Also remember the difference in naming conventions between HTML and javascript. i.e. 'course-title' in HTML is referred to as 'courseTitle' in javascript.

Keep on keepin' on, bro.

So basically the answer should be:

console.log($attrs.courseTitle);

Hi Nick,

What's the question please?

Nick Marsh
Nick Marsh
14,763 Points

Hi Salman,

The question is

Look at the <div> element with the treehouse-course directive in index.html. Then update the directive in app.js to call console.log with the value of the course-title attribute.

Nick Marsh
Nick Marsh
14,763 Points

Still having trouble with this one. If anyone can point me in the right direction, it would be much appreciated.

Nick Marsh
Nick Marsh
14,763 Points

Thanks! That did it.