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

Nick Marsh
Nick Marsh
14,255 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,255 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,255 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,255 Points

Thanks! That did it.