Skip to content

Commit 29ec2ac

Browse files
committed
fixed templateUrl not requesting from BE
1 parent 213a33d commit 29ec2ac

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

app/tour_helpers.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
(function (app) {
44
'use strict';
55

6-
app.factory('TourHelpers', ['$templateCache', '$compile', 'TourConfig', function ($templateCache, $compile, TourConfig) {
6+
app.factory('TourHelpers', ['$templateCache', '$http', '$compile', 'TourConfig', function ($templateCache, $http, $compile, TourConfig) {
77

88
var helpers = {},
99
safeApply;
@@ -49,17 +49,18 @@
4949
*
5050
* @param {String} templateUrl
5151
* @param {$rootScope.Scope} scope
52-
* @returns {Function}
52+
* @returns {Promise}
5353
*/
5454
function lookupTemplate(templateUrl, scope) {
5555

56-
var template = $templateCache.get(templateUrl);
57-
58-
if (template) {
59-
return compileTemplate(template, scope);
60-
}
61-
62-
return null;
56+
return $http.get(templateUrl, {
57+
cache: $templateCache
58+
}).success(function (template) {
59+
if (template) {
60+
return compileTemplate(template, scope);
61+
}
62+
return '';
63+
});
6364

6465
}
6566

@@ -94,14 +95,18 @@
9495
template = compileTemplate(scope.$eval(attrs[helpers.getAttrName('template')]), scope);
9596
}
9697

97-
if (attrs[helpers.getAttrName('templateUrl')]) {
98-
template = lookupTemplate(attrs[helpers.getAttrName('templateUrl')], scope);
99-
}
100-
10198
if (template) {
10299
options.template = template;
103100
}
104101

102+
if (attrs[helpers.getAttrName('templateUrl')]) {
103+
lookupTemplate(attrs[helpers.getAttrName('templateUrl')], scope).then(function (template) {
104+
if (template) {
105+
options.template = template;
106+
}
107+
});
108+
}
109+
105110
};
106111

107112
/**

0 commit comments

Comments
 (0)