Reputation: 23
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?
Upvotes: 0
Views: 1800
Reputation: 101652
You need to call test2
.
test: function () {
var text = this.test2(); // <-- here
return text;
},
Upvotes: 1