Skip to content

Commit b3a9bd3

Browse files
fix($templateRequest): cache downloaded templates as strings
Fixes angular#10630 Closes angular#10646
1 parent 31a5b83 commit b3a9bd3

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/ng/templateRequest.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function $TemplateRequestProvider() {
4444
handleRequestFn.totalPendingRequests--;
4545
})
4646
.then(function(response) {
47+
$templateCache.put(tpl, response.data);
4748
return response.data;
4849
}, handleError);
4950

test/ng/templateRequestSpec.js

Lines changed: 2 additions & 1 deletion
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)