I have a route setup like this:
var myApp = angular.module('myApp', []).
config(['$routeProvider', function ($routeProvider) {
$routeProvider.
when('/landing', {
templateUrl: '/landing-partial',
controller: landingController
}).
when('/:wkspId/query', {
templateUrl: '/query-partial',
controller: queryController
}).
otherwise({
redirectTo: '/landing'
});
}]);
I want to be able to make angularjs download both the partials in the beginning and not when requested.
Is it possible?
Yes, there are at least 2 solutions for this:
scriptdirective (http://docs.angularjs.org/api/ng.directive:script) to put your partials in the initially loaded HTML$templateCache(http://docs.angularjs.org/api/ng.$templateCache) from JavaScript if needed (possibly based on result of$httpcall)If you would like to use method (2) to fill in
$templateCacheyou can do it like this:Of course the templates content could come from a
$httpcall:Here is the plunker those techniques: http://plnkr.co/edit/J6Y2dc?p=preview