There's a callback in line 64.  templateDeferred is only resolved after templateHtml is assigned.  The deferred object returned by sendRequest will be resolved before the callback is executed, and templateHtml will not be assigned.