Skip to content

Commit 39eef70

Browse files
feat($templateRequest): support configuration of $http options
It is now possible to configure the options sent to $http for template requests. If no value is configured then the request will use the default $http options. Thanks to @luckycadow for help on this feature Closes angular#11868 Closes angular#6860
1 parent cb43c23 commit 39eef70

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

test/ng/templateRequestSpec.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ describe('$templateRequest', function() {
3131

3232
function someTransform() {}
3333

34-
var expectedHeader;
35-
3634
module(function($templateRequestProvider, $httpProvider) {
3735

3836
// Configure the template request service to provide specific headers and transforms
@@ -54,6 +52,30 @@ describe('$templateRequest', function() {
5452
});
5553
});
5654
});
55+
56+
57+
it('should be allow you to override the cache', function() {
58+
59+
var httpOptions = {};
60+
61+
module(function($templateRequestProvider, $httpProvider) {
62+
$templateRequestProvider.httpOptions(httpOptions);
63+
});
64+
65+
inject(function($templateRequest, $http, $cacheFactory) {
66+
spyOn($http, 'get').andCallThrough();
67+
68+
var customCache = $cacheFactory('customCache');
69+
httpOptions.cache = customCache;
70+
71+
$templateRequest('tpl.html');
72+
73+
expect($http.get).toHaveBeenCalledOnceWith('tpl.html', {
74+
cache: customCache,
75+
transformResponse: []
76+
});
77+
});
78+
});
5779
});
5880
});
5981

0 commit comments

Comments
 (0)