mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-01-12 22:45:52 +08:00
fix($emplateRequest): propagate rejection reason when ignoreRequestError flag is set
Closes #10266
This commit is contained in:
@@ -48,12 +48,12 @@ function $TemplateRequestProvider() {
|
||||
return html;
|
||||
}, handleError);
|
||||
|
||||
function handleError() {
|
||||
function handleError(resp) {
|
||||
self.totalPendingRequests--;
|
||||
if (!ignoreRequestError) {
|
||||
throw $compileMinErr('tpload', 'Failed to load template: {0}', tpl);
|
||||
}
|
||||
return $q.reject();
|
||||
return $q.reject(resp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,20 @@ describe('$templateRequest', function() {
|
||||
}).toThrowMinErr('$compile', 'tpload', 'Failed to load template: tpl.html');
|
||||
}));
|
||||
|
||||
it('should not throw when the template is not found and ignoreRequestError is true',
|
||||
inject(function($rootScope, $templateRequest, $httpBackend) {
|
||||
|
||||
$httpBackend.expectGET('tpl.html').respond(404);
|
||||
|
||||
var err;
|
||||
$templateRequest('tpl.html', true).catch(function(reason) { err = reason; });
|
||||
|
||||
$rootScope.$digest();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(err.status).toBe(404);
|
||||
}));
|
||||
|
||||
it('should not throw an error when the template is empty',
|
||||
inject(function($rootScope, $templateRequest, $httpBackend) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user