diff --git a/src/templateFactory.js b/src/templateFactory.js index ebb86d353..ca491a987 100644 --- a/src/templateFactory.js +++ b/src/templateFactory.js @@ -83,7 +83,7 @@ function $TemplateFactory( $http, $templateCache, $injector) { if (isFunction(url)) url = url(params); if (url == null) return null; else return $http - .get(url, { cache: $templateCache }) + .get(url, { cache: $templateCache, headers: { Accept: 'text/html' }}) .then(function(response) { return response.data; }); }; diff --git a/test/templateFactorySpec.js b/test/templateFactorySpec.js index f330dadc2..ff72dd303 100644 --- a/test/templateFactorySpec.js +++ b/test/templateFactorySpec.js @@ -1,8 +1,16 @@ describe('templateFactory', function () { - + beforeEach(module('ui.router.util')); it('exists', inject(function ($templateFactory) { expect($templateFactory).toBeDefined(); })); + + it('should request templates as text/html', inject(function($templateFactory, $httpBackend) { + $httpBackend.expectGET('views/view.html', function(headers) { + return headers.Accept === 'text/html'; + }).respond(200); + $templateFactory.fromUrl('views/view.html'); + $httpBackend.flush(); + })); });