控制器内部的代码是:
(function(){
$scope.show();
profile.friend_requests_to_me_service(loggedInUser.id).then(function(data){
console.log(data);
$scope.friend_requests_to_me = data.data.friend_request_to_me;
$scope.friends = data.data.people_you_may_know;
$scope.hide();
});
})();
如您所见,此函数正在调用服务配置文件和该服务的方法。问题是此调用函数不起作用。给出错误:
TypeError: (intermediate value)(...) is not a function
。在 plunker 中,我检查了一个琐碎的自调用函数。这是链接:http: //jsfiddle.net/Lvc0u55v/4582/。这个微不足道的自调用功能正在工作。但我不明白为什么我的实际应用程序自调用功能不起作用。谢谢您的时间。
目前的工作版本(非自调用)是:
$scope.friendship_requests_to_me_function = function(){
$scope.show();
profile.friend_requests_to_me_service(loggedInUser.id).then(function(data){
console.log(data);
$scope.friend_requests_to_me = data.data.friend_request_to_me;
$scope.friends = data.data.people_you_may_know;
$scope.hide();
});
}
$scope.friendship_requests_to_me_function();