Skip to content

Commit 189462b

Browse files
fix($templateRequest): cache downloaded templates as strings
Fixes angular#10630
1 parent 35aec52 commit 189462b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/ng/templateRequest.js

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function $TemplateRequestProvider() {
4242

4343
return $http.get(tpl, httpOptions)
4444
.then(function(response) {
45+
$templateCache.put(tpl, response.data);
4546
self.totalPendingRequests--;
4647
return response.data;
4748
}, handleError);

test/ng/templateRequestSpec.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('$templateRequest', function() {
1717
}));
1818

1919
it('should cache the request to prevent extra downloads',
20-
inject(function($rootScope, $templateRequest, $httpBackend) {
20+
inject(function($rootScope, $templateRequest, $templateCache, $httpBackend) {
2121

2222
$httpBackend.expectGET('tpl.html').respond('matias');
2323

@@ -34,6 +34,7 @@ describe('$templateRequest', function() {
3434

3535
expect(content[0]).toBe('matias');
3636
expect(content[1]).toBe('matias');
37+
expect($templateCache.get('tpl.html')).toBe('matias');
3738
}));
3839

3940
it('should throw an error when the template is not found',

0 commit comments

Comments
 (0)