Angularjs 在服务内部共享函数 [英] Angularjs share functions inside service
本文介绍了Angularjs 在服务内部共享函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用一个 angular 应用程序,其中的服务声明如下:
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?
}
}
我想在calculation2方法中使用util函数.
I want to use util function inside calculation2 method.
我该怎么做?
提前致谢.
推荐答案
只需在calculation1
函数外声明即可:
Just declare it outside the calculation1
function:
App.service("myService", function(){
var util = function(){
}
this.calculation1 = function(){
//doing something
}
this.calculation2 = function(){
}
}
这篇关于Angularjs 在服务内部共享函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文