user975060
user975060

Reputation: 335

Angular View fails to load from template, when rendered via PhantomJS

I have an Angular application that is leveraging template caching (part of our Gulp build process). The application runs fine, the cached views load... Except when rendered through PhantomJS (or Google's Pagespeed or Fetch as Google for that matter).

After much investigation, I found that routing is throwing this error:

Error: [$compile:tpload] Failed to load template: /static/app/public/views/about.html (HTTP status: undefined undefined)

I am assuming the HTTP status of undefined is related to the fact that no round trip is occurring... but I can't find any information on why this would fail, and especially why only when using the above mentioned tools.

To summarize:

Edit

I added the following line for debugging:

    var about = $templateCache.get('/static/app/public/views/about.html');
    console.log('about', about);    

... and I see the proper output in the console log, even with PhantomJS.

Upvotes: 0

Views: 420

Answers (1)

user975060
user975060

Reputation: 335

It turns out that I was ignoring another error message:

Error: undefined is not a constructor (evaluating 'newUrl.startsWith(target)')

... happening due to PhantomJS's ES5. I didn't think the two issues were related, but after providing a polyfill for String.prototype.startsWith, the issue went away.

Upvotes: 1

Related Questions