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 Services and Dependencies Services: Requiring factories

Jason Saba
Jason Saba
Courses Plus Student 3,862 Points

Not sure what I'm doing wrong here, I've passed the factory into the controllers function? Any guidance would be helpful

How am I logging it wrong?

angular.module('treehouseCourse', [])
  .factory('Course', function() {
    return {
      title: "Intro to Angular"

angular.module('treehouseCourse', [])
  .controller('MyCourseCtrl', ['$scope', 'Course', function ($scope, Course) {
<!DOCTYPE html>
<html ng-app="treehouseCourse">
    <script src="js/angular.js"></script>
    <script src="app.js"></script>
  <body ng-controller="MyCourseCtrl">

1 Answer

Jason Saba
Jason Saba
Courses Plus Student 3,862 Points

the answer was this...

var myApp = angular.module('treehouseCourse', []);

myApp.factory('Course', function() { return { title: "Intro to Angular" } });

myApp.controller('MyCourseCtrl', ['$scope', 'Course', function ($scope, Course) { console.log(Course); }]);

... The Comment must have been throwing it off