0

Im trying to call a returning function inside another returning function but I'm getting myfunctionName is undefined.. here is the code

function(){
... 
....
return{
      myfunction1: function(param1,param2){
        var doSomethingHere;
      },
      myfunction2: function(){
          ....
          var param1,param2
          .... 
          //I get an error here
          myfunction1(param1,param2).then(function(return){
             console.log(return);
          });
      }
    }
}  

so how can I call myfunction1 inside myFunction2 whiouth getting the error "is not defined"

4

1 回答 1

0

揭示模块模式可以帮助解决这个问题

function(){
    var myfunction1 = function(param1,param2){
        var doSomethingHere;
    }

    var myfunction2 = function(){
          ....
          var param1,param2
          .... 
          //I get an error here
          myfunction1(param1,param2).then(function(return){
             console.log(return);
          });
    }

    return{
      myfunction1: myfunction1,
      myfunction2: myfunction2
    }
}  
于 2014-07-10T19:30:23.543 回答