Skip to content

Commit 9376fc0

Browse files
committed
Merge pull request #1341 from jimobrien/feat/templateFactory
feat($templateFactory): request templateURL as text/html
2 parents 7d51c4a + ccd6076 commit 9376fc0

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/templateFactory.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function $TemplateFactory( $http, $templateCache, $injector) {
8383
if (isFunction(url)) url = url(params);
8484
if (url == null) return null;
8585
else return $http
86-
.get(url, { cache: $templateCache })
86+
.get(url, { cache: $templateCache, headers: { Accept: 'text/html' }})
8787
.then(function(response) { return response.data; });
8888
};
8989

test/templateFactorySpec.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
describe('templateFactory', function () {
2-
2+
33
beforeEach(module('ui.router.util'));
44

55
it('exists', inject(function ($templateFactory) {
66
expect($templateFactory).toBeDefined();
77
}));
8+
9+
it('should request templates as text/html', inject(function($templateFactory, $httpBackend) {
10+
$httpBackend.expectGET('views/view.html', function(headers) {
11+
return headers.Accept === 'text/html';
12+
}).respond(200);
13+
$templateFactory.fromUrl('views/view.html');
14+
$httpBackend.flush();
15+
}));
816
});

0 commit comments

Comments
 (0)