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 trialjason chan
31,009 PointsCreate a method named testingMyService on the service that logs the string, "This is my service!" when called. E.g.: myS
stuck
angular.module('foobar', [])
.service('myService', function testingMyService (service){
this.service = function () {
console.log("This is my service!");
},
myService.testingMyService()
})
;
3 Answers
jason chan
31,009 Pointsangular.module('foobar', [])
.service('myService', function myService(){
this.testingMyService = function(){
console.log("This is my service!")
};
});
SOLVED
Abdulrahman D
16,420 Pointsangular.module('foobar', [])
.service('myService', function(){
this.testingMyService = function(){
console.log("This is my service!")
};
});
The callback function should be anonymous.
Samuel Gates
1,181 Pointsof course, you don't need to define your function as myService for it to work.
Justin Lovato
1,629 PointsJustin Lovato
1,629 PointsI had the exact same code but had to use "myService" with double quotes instead of 'myService' in single quotes. Hopes this helps somebody.