Skip to content

Commit

Permalink
feat($templateFactory): request templateURL as text/html
Browse files Browse the repository at this point in the history
Add "Accept: text/html" to headers of $http.get invocation

Closes issue #1287
  • Loading branch information
jimobrien committed Sep 6, 2014
1 parent 7d51c4a commit ccd6076
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/templateFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; });
};

Expand Down
10 changes: 9 additions & 1 deletion test/templateFactorySpec.js
Original file line number Diff line number Diff line change
@@ -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();
}));
});

0 comments on commit ccd6076

Please sign in to comment.