Skip to content

Commit

Permalink
Merge pull request #213 from nhardy/master
Browse files Browse the repository at this point in the history
getTemplate() should always return a Promise
  • Loading branch information
45kb committed Jun 20, 2017
2 parents d29be43 + ea0bdec commit 2e749ee
Showing 1 changed file with 11 additions and 11 deletions.
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

0 comments on commit 2e749ee

Please sign in to comment.