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 trialPhillip Sanders
1,415 PointsIntroduction to Angular Factory Question
I am stuck on something that appears to be correct and and does log the desired information to the console, yet I the code does not pass. I have researched this question and everything I have found tells me I am doing this correctly. Is there a bug in the lesson?
angular.module('treehouseCourse', [])
.factory('Course', function() {
return {
title: "Intro to Angular"
}
});
angular.module('treehouseCourse')
.controller('MyCourseCtrl',["$scope","Course",function($scope,Course){
console.log(Course.title);
}])
<!DOCTYPE html>
<html ng-app="treehouseCourse">
<head>
<title>Angular.js</title>
<script src="js/angular.js"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MyCourseCtrl">
</body>
</html>
5 Answers
Aaron Brewer
7,939 Pointsangular.module('treehouseCourse', [])
.factory('Course', function() {
return {
title: 'Intro to Angular'
}
});
angular.module('treehouseCourse')
.controller('MyCourseCtrl', ['$scope', 'Course', function($scope, Course){
console.log(Course.title);
}]);
The above works, and is done how it should be from what I understand. You definitely did it right.
Phillip Sanders
1,415 PointsThank you... Now if only that answer satisfied the lesson.
Aaron Brewer
7,939 PointsTheir test may just have a bug in it? Alex Vanston , can you help us out here?
Sidney Casagrande
7,035 PointsI'm having the same issue here. Hope we get a fast resolution for this issue, or at least some clarification.
erika harvey
Courses Plus Student 14,540 Pointsits still not working or passing with any suggestions, i went ahead and asked my professor who came up with the same answer we have and it wouldn't pass. I checked wiht Angular up and running by O'reilly and I don't see where our problem is.
Charlie Ryan
1,434 PointsOkay, I figured it out, we're all being too clever and over thinking it :)
The question says "Within the controller, log the injected factory to the console using console.log.", and we were all logging the title attribute.
The correct answer is:
.controller('MyCourseCtrl', ['$scope', 'Course', function($scope, Course){
console.log( Course );
}]);