Function inside factory method can communicate
angularjs
Solution
Why not do something like this:
app.factory("fact1",function(){
function funct1 () {
// Do some code...
}
function funct2 () {
// Do some code...
funct1();
}
return{
funct1: funct1,
funct2: funct2
};
});
I've personally found this way to be much more usable/readable than stashing every function in my return object. Also, I'm not a big fan of using `this` in my return objects.
Problem
i have one doubt regarding the factory directory of angular js. suppose this is fact1 directory .I want to call funct1 method inside the funct2 method. ``` app.factory("fact1",function(){ return{ funct1:function(){ //some code here },funct2:function(){ //some code here // call here funct1() } } }); ``` first tell me this is possible or not? if possible then how i can call funct1 method inside the funct2 method.