0

The code inside the controller is:

(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();
    });   
})();

As you can see this function is calling the service profile and a method of that service.The problem is that this invoking function is not working.The error is given: TypeError: (intermediate value)(...) is not a function.In plunker i have checked a trivial self invoking function.Here is the link:http://jsfiddle.net/Lvc0u55v/4582/. This trivial self invoking function is working.But I cant understand why my actual app self invoking function is not working.Thank you for your time.

The present working version(non self invoking) is: $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();

3
  • With uglify? Try add a ";' before your self invoking function. Commented May 27, 2016 at 13:37
  • @YinGang yes it is working Commented May 27, 2016 at 13:38
  • Didnt understand what was the problem?No where in the documentation is given this syntax.@YinGang if you can provide me an answer i can accept it Commented May 27, 2016 at 13:39

1 Answer 1

1

Most probably one of your js statement is missing a ';' at the end.

Try add a ';' before your self invoking function.

Read more here

We end up passing the second function as an argument to the first function and then trying to call the result of the first function call as a function. The second function will fail with a "... is not a function" error at runtime.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.