Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9a1af98

Browse files
anantanandguptachristopherthielen
authored andcommittedDec 9, 2016
use $templateRequest from AngularJS
- modified `$templateFactory` to use `$templateRequest` provider of AngularJs in case it is avalable - removed the test case which enforces the setting of request header `Accept: text/html`
1 parent 67e4997 commit 9a1af98

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed
 

‎src/templateFactory.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,15 @@ function $TemplateFactory( $http, $templateCache, $injector) {
8282
this.fromUrl = function (url, params) {
8383
if (isFunction(url)) url = url(params);
8484
if (url == null) return null;
85-
else return $http
86-
.get(url, { cache: $templateCache, headers: { Accept: 'text/html' }})
87-
.then(function(response) { return response.data; });
85+
else {
86+
if($injector.has('$templateRequest')) {
87+
return $injector.get('$templateRequest')(url);
88+
} else {
89+
return $http
90+
.get(url, { cache: $templateCache, headers: { Accept: 'text/html' }})
91+
.then(function(response) { return response.data; });
92+
}
93+
}
8894
};
8995

9096
/**

‎test/templateFactorySpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('templateFactory', function () {
66
expect($templateFactory).toBeDefined();
77
}));
88

9-
it('should request templates as text/html', inject(function($templateFactory, $httpBackend) {
9+
xit('should request templates as text/html', inject(function($templateFactory, $httpBackend) {
1010
$httpBackend.expectGET('views/view.html', function(headers) {
1111
return headers.Accept === 'text/html';
1212
}).respond(200);

0 commit comments

Comments
 (0)
Please sign in to comment.