Skip to content

Commit 45066e9

Browse files
author
Nathan Hardy
committed
getTemplate() should always return a Promise
1 parent d29be43 commit 45066e9

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

dist/angular-tooltips.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* http://720kb.github.io/angular-tooltips
77
*
88
* MIT license
9-
* Tue May 23 2017
9+
* Tue Jun 20 2017
1010
*/
1111
@-webkit-keyframes animate-tooltip {
1212
0% {

dist/angular-tooltips.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* http://720kb.github.io/angular-tooltips
77
*
88
* MIT license
9-
* Tue May 23 2017
9+
* Tue Jun 20 2017
1010
*/
1111
/*global angular,window*/
1212
(function withAngular(angular, window) {
@@ -279,7 +279,7 @@
279279
}
280280
};
281281
}
282-
, tooltipDirective = /*@ngInject*/ ['$log', '$http', '$compile', '$timeout', '$controller', '$injector', 'tooltipsConf', '$templateCache', function tooltipDirective($log, $http, $compile, $timeout, $controller, $injector, tooltipsConf, $templateCache) {
282+
, tooltipDirective = /*@ngInject*/ ['$log', '$http', '$compile', '$timeout', '$controller', '$injector', 'tooltipsConf', '$templateCache', '$q', function tooltipDirective($log, $http, $compile, $timeout, $controller, $injector, tooltipsConf, $templateCache, $q) {
283283

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

@@ -541,17 +541,17 @@
541541

542542
var template = $templateCache.get(tooltipTemplateUrl);
543543

544-
if (typeof template === 'undefined') {
545-
546-
// How should failing to load the template be handled?
547-
template = $http.get(tooltipTemplateUrl).then(function onGetTemplateSuccess(response) {
548-
549-
return response.data;
550-
});
551-
$templateCache.put(tooltipTemplateUrl, template);
544+
if (typeof template !== 'undefined') {
545+
// Wrap template in a Promise so that getTemplate always returns a Promises
546+
return $q.resolve(template);
552547
}
553-
554-
return template;
548+
549+
// How should failing to load the template be handled?
550+
return $http.get(tooltipTemplateUrl).then(function onGetTemplateSuccess(response) {
551+
$templateCache.put(tooltipTemplateUrl, response.data);
552+
553+
return response.data;
554+
});
555555
}
556556
, onTooltipTemplateChange = function onTooltipTemplateChange(newValue) {
557557

dist/angular-tooltips.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-tooltips.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)