Q:

Angular: immediately return from ngClick function

I have a dropdown menu on my page, which is really just an unordered list, where each menu item looks like:
<li ng-click='doCalc(5)'>Five</li>

Now, the function that doCalc calls might take a little while:
function doCalc(num) {
  factorial(num);
}

This means that the menu stays on the screen while factorial runs.   What I'd like is for doCalc to return immediately, not waiting for factorial to finish running. 
I know how to do this with a no-delay setTimeout, and with a promise.   But what's the Angular Way to do this?  Searching for "angular promise" yields a sea of results about HTTP requests, when here I am just doing a humble calculation. 

A:

A promise can be created with either the $q service or the $timeout service. 
function doCalc(num) {
    return $q.when(factorial(num));
};

Or
function doCalc(num) {
    return $timeout(function() {return factorial(num)}, 0);
};

Is there a preference for one or the other?  If I have lots of async requests also going on in the page, will when be blocked? 

Both the $q service  and the $timeout service use the $q queue (and below that setTimeout).  Be aware that both the browser queue and the Angular $q queue operate on a single thread.  That means that once the factorial function starts, it runs to completion.  If you are concerned about the factorial service causing problems with other asychronous operations, then that function needs to be broken up with multiple calls to $q.when or $timeout (which both ultimately call setTimeout).