Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


template caching bug #455

tylercollier opened this Issue · 7 comments

5 participants


I'm not sure if this is a bug with angular-strap. It might be an angularjs bug.

Here's my original question: It mentions this plunker demo:

As @calebboyd discovered and answered on stackoverflow, the issue is with template caching.

At, the $templateCache is returning with an array of the previous $http.get() call. That's odd; it should be an object with a .data property. Thus the subsequent code fails without a legit template.

I'm using angular 1.2.2 right now, but the problem also exists with 1.2.12 (as shown by my plunker link). I'm guessing this is an angular bug? Can you confirm?

@calebboyd created a quick solution by replacing those two lines with the following code (or see this plunker:

return $q.when($templateCache.get(options.contentTemplate) && $templateCache.get(options.contentTemplate)[1] || $http.get(options.contentTemplate, { cache: $templateCache })
              .then(function (contentTemplate) {

I fixed it for myself by not using $templateCache but just using

$http.get(options.contentTemplate, { cache: true })

instead of

$http.get(options.contentTemplate, { cache: $templateCache })

I see this has already been changed in master. But It doesn't really make sense to keep the template in $http's $cacheFactory. As the user(dev) might want to use it elsewhere. Why not just use a utility method to do something like:

function getTemplate(template){
    return $http.get(template).then(function(response){

It's not fixed in the master dist directory though. See:

@mgcrea feel free to close this then but I'm curious as to why you took the caching out altogether with 24545fe. Perhaps you set a default caching option somewhere; I didn't look.


@tylercollier I will issue a new release very soon. Dropped the cache support to follow the global $http configuration defined for any app. Indeed having a getTemplate-like function might be interesting to properly leverage $templateCache.


Awesome. I'll let you close this when you want, or you can leave it open as a reminder. Up to you. Thanks for Angular-Strap and congrats on its success!

@mgcrea mgcrea closed this in aa83097

Fix is incorrect both 2.0.5 and 2.1.0 are not working with templates cached by ng-include

Correct fix is to simplify fetchTemplate:
function fetchTemplate(template) {
return $http.get(template, {cache: $templateCache});


@morgun would be great if you could add an unit test for this.


Can you please fix this asap? It's really creating headaches for me...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.