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?
You can pass $state to your controller and then when the page loads and calls the getter in the controller you call $state.go('index') or whatever partial you want to load. Done.
Add a build task to concatenate and register your html partials in the Angular
$templateCache
. (This answer is a more detailed variant of karlgold's answer.)For grunt, use grunt-angular-templates. For gulp, use gulp-angular-templatecache.
Below are config/code snippets to illustrate.
gruntfile.js Example:
gulpfile.js Example:
templates.js (this file is autogenerated by the build task)
index.html