我有一个功能:
function method($scope, $timeout, shLoadCountryService)
{
function getDate(){
/somecode
}
$scope.submit = function (userResponse, parameters)
{
getDate();
//code
}
shLoadCountryService.loadCountry(arguments.callee.name, arguments);
}
function customized_method($scope, $timeout, shLoadCountryService)
{
$scope.submit = function (userResponse, parameters)
{
getDate();
//code
}
}
angular.module("mobile")
.factory("shLoadCountryService", ["shMainScopeService", function (shMainScopeService) {
var self = this;
function loadCountry(name, params) {
var methodName = shMainScopeService.scope.product + '_' + name;
if (typeof window[methodName] === "function") {
window[methodName].apply(this, params);
}
};
self.loadCountry = loadCountry;
return self;
}]
);
如果设置了scope.product,则应从customized_method()
此部分工作替换提交。但是在submit方法中我们调用getDate()
,它在base函数中定义。
运行时,我得到ReferenceError: getTodayDate is not defined
有没有办法从第二个函数应用函数,仍然可以使用base中的函数?