如何解决angularjs 服务工厂函数不是函数
我正在调用一个服务函数,并在处理的结果中调用另一个服务函数。第一个(外部)工作,处理结果,并根据结果,然后调用第二个服务函数。但是,第二个服务函数返回错误 clientService.getClient(...).then is not a function
。其服务工厂相同,功能设置和调用完全相同。
.factory("clientService",function($http,$q) {
function getDataSet(typeID) {
// retrieve full data client list from server
}
function getClient(id,typeID) {
// return client data from already retrieved full client list
}
return {
getDataSet: function(typeID) {
return getDataSet(typeID) ;
},getClient: function(id,typeID) {
return getClient(id,typeID) ;
}
}
})
...在我的控制器中我正在调用
clientService.getDataSet(2) // <-- works fine
.then(function(response) {
if (response.list != null) {
$scope.clientsList = response.list ; // <-- list retrieved successfully
if ($stateParams.openID) {
clientService.getClient($stateParams.openID,2) // <-- Error: "clientService.getClient(...).then is not a function"
.then(function(clientResponse) {
// process client data
}) ;
}
} else {
logResponse("Client list was is empty") ;
}
}) ;
我被这个弄糊涂了。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。