Skip to content

Commit

Permalink
feat($templateFactory): use $templateRequest on 1.3
Browse files Browse the repository at this point in the history
Fixes #1882
  • Loading branch information
nateabele committed Apr 21, 2015
1 parent 0250291 commit a8b529b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ module.exports = function (grunt) {
}
});

grunt.registerTask('integrate', ['build', 'jshint', 'karma:unit', 'karma:past', 'karma:unstable']);
grunt.registerTask('integrate', ['build', 'jshint', 'karma:unit', 'karma:past', 'karma:unstable', 'karma:future']);
grunt.registerTask('default', ['build', 'jshint', 'karma:unit']);
grunt.registerTask('build', 'Perform a normal build', ['concat', 'uglify']);
grunt.registerTask('dist', 'Perform a clean build', ['clean', 'build']);
Expand Down
14 changes: 11 additions & 3 deletions src/templateFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
$TemplateFactory.$inject = ['$http', '$templateCache', '$injector'];
function $TemplateFactory( $http, $templateCache, $injector) {

var $templateRequest = (
$injector.has &&
$injector.has('$templateRequest') &&
$injector.get('$templateRequest')
);

/**
* @ngdoc function
* @name ui.router.util.$templateFactory#fromConfig
Expand Down Expand Up @@ -82,9 +88,11 @@ function $TemplateFactory( $http, $templateCache, $injector) {
this.fromUrl = function (url, params) {
if (isFunction(url)) url = url(params);
if (url == null) return null;
else return $http
.get(url, { cache: $templateCache, headers: { Accept: 'text/html' }})
.then(function(response) { return response.data; });

return ($templateRequest && $templateRequest(url) || $http.get(url, {
cache: $templateCache,
headers: { Accept: 'text/html' }
})).then(function(response) { return response.data; });
};

/**
Expand Down

0 comments on commit a8b529b

Please sign in to comment.