Skip to content

Instantly share code, notes, and snippets.

@justinobney
Created July 1, 2013 14:37
Show Gist options
  • Save justinobney/5901385 to your computer and use it in GitHub Desktop.
Save justinobney/5901385 to your computer and use it in GitHub Desktop.
Preload all templates
angular.module('app', [])
.run(['$route', '$http', '$templateCache', function($route, $http, $templateCache) {
// Cache all templates on App Start
angular.forEach($route.routes, function(r) {
if (r.templateUrl) {
$http.get(r.templateUrl, {cache: $templateCache});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment