1

I am working with an angular app, where service are as declared as follows:

App.service("myService", function(){
  this.calculation1 = function(){
    var util = function(){
    }
    //doing somthing
  }
  this.calculation2 = function(){

    // how can I call util function here?
  }
}

I want to use util function inside calculation2 method.

How can I do that?

Thanks in advance.

joakimbl
  • 18,081
  • 5
  • 54
  • 53
arnold
  • 1,682
  • 8
  • 24
  • 31

1 Answers1

3

Just declare it outside the calculation1 function:

App.service("myService", function(){
  var util = function(){
  }
  this.calculation1 = function(){
    //doing something
  }
  this.calculation2 = function(){

  }
}
Linh Pham
  • 3,005
  • 23
  • 34