I have a AngularJS application that has a service module. I have simplyfied what i want to do in the code below. I want one service function to get a value from another function in the same service.
service.factory(....)
return {
//test function want to get the value from "info" in test2.
test: function () {
var text = this.test2;
return text;
},
test2: function () {
var info = "Hello World";
return info;
}
When i call "test" function it returns the entire function:
function () {
var info = "Hello World";
return info;
}
and not the "Hello World". Can someone explain why its not returning the value?
1 Answer 1
You need to call test2.
test: function () {
var text = this.test2(); // <-- here
return text;
},
answered Mar 19, 2015 at 10:20
JLRishe
102k19 gold badges138 silver badges171 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Jenkaa
Thank you. Abit annoying to miss it :(
lang-js