Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit e909b92

Browse files
realitykingrvanbaalen
authored and
rvanbaalen
committed
refactor(modal,typeahead) Use $templateRequest
1 parent f02c1bb commit e909b92

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

Diff for: src/modal/modal.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -365,17 +365,14 @@ angular.module('ui.bootstrap.modal', [])
365365
backdrop: true, //can also be false or 'static'
366366
keyboard: true
367367
},
368-
$get: ['$injector', '$rootScope', '$q', '$http', '$templateCache', '$controller', '$modalStack',
369-
function ($injector, $rootScope, $q, $http, $templateCache, $controller, $modalStack) {
368+
$get: ['$injector', '$rootScope', '$q', '$templateRequest', '$controller', '$modalStack',
369+
function ($injector, $rootScope, $q, $templateRequest, $controller, $modalStack) {
370370

371371
var $modal = {};
372372

373373
function getTemplatePromise(options) {
374374
return options.template ? $q.when(options.template) :
375-
$http.get(angular.isFunction(options.templateUrl) ? (options.templateUrl)() : options.templateUrl,
376-
{cache: $templateCache}).then(function (result) {
377-
return result.data;
378-
});
375+
$templateRequest(angular.isFunction(options.templateUrl) ? (options.templateUrl)() : options.templateUrl);
379376
}
380377

381378
function getResolvePromises(resolves) {

Diff for: src/typeahead/typeahead.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
380380
};
381381
})
382382

383-
.directive('typeaheadMatch', ['$http', '$templateCache', '$compile', '$parse', function ($http, $templateCache, $compile, $parse) {
383+
.directive('typeaheadMatch', ['$templateRequest', '$compile', '$parse', function ($templateRequest, $compile, $parse) {
384384
return {
385385
restrict:'EA',
386386
scope:{
@@ -390,10 +390,10 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
390390
},
391391
link:function (scope, element, attrs) {
392392
var tplUrl = $parse(attrs.templateUrl)(scope.$parent) || 'template/typeahead/typeahead-match.html';
393-
$http.get(tplUrl, {cache: $templateCache}).success(function(tplContent){
394-
$compile(tplContent.trim())(scope, function(clonedElement){
395-
element.replaceWith(clonedElement);
396-
});
393+
$templateRequest(tplUrl).then(function(tplContent) {
394+
$compile(tplContent.trim())(scope, function(clonedElement){
395+
element.replaceWith(clonedElement);
396+
});
397397
});
398398
}
399399
};

0 commit comments

Comments
 (0)