Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
getTemplate() should always return a Promise
  • Loading branch information
Nathan Hardy committed Jun 20, 2017
commit ea0bdec9666eb6f6cbfda10164731fb1650be48c
22 changes: 11 additions & 11 deletions lib/angular-tooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
}
};
}
, tooltipDirective = /*@ngInject*/ ['$log', '$http', '$compile', '$timeout', '$controller', '$injector', 'tooltipsConf', '$templateCache', function tooltipDirective($log, $http, $compile, $timeout, $controller, $injector, tooltipsConf, $templateCache) {
, tooltipDirective = /*@ngInject*/ ['$log', '$http', '$compile', '$timeout', '$controller', '$injector', 'tooltipsConf', '$templateCache', '$q', function tooltipDirective($log, $http, $compile, $timeout, $controller, $injector, tooltipsConf, $templateCache, $q) {

var linkingFunction = function linkingFunction($scope, $element, $attrs, $controllerDirective, $transcludeFunc) {

Expand Down Expand Up @@ -531,17 +531,17 @@

var template = $templateCache.get(tooltipTemplateUrl);

if (typeof template === 'undefined') {

// How should failing to load the template be handled?
template = $http.get(tooltipTemplateUrl).then(function onGetTemplateSuccess(response) {

return response.data;
});
$templateCache.put(tooltipTemplateUrl, template);
if (typeof template !== 'undefined') {
// Wrap template in a Promise so that getTemplate always returns a Promise
return $q.resolve(template);
}

return template;

// How should failing to load the template be handled?
return $http.get(tooltipTemplateUrl).then(function onGetTemplateSuccess(response) {
$templateCache.put(tooltipTemplateUrl, response.data);

return response.data;
});
}
, onTooltipTemplateChange = function onTooltipTemplateChange(newValue) {

Expand Down