Can i use $templateCache in ui-router's template?
The template will be cached in resolve section and i want to use cached template in the same state.
$stateProvider
.state('dashboard', {
url: "/dashboard",
template: function($templateCache){
console.log('test 2');
return $templateCache.get('templates/template1.html'); // returns undefined
},
resolve:{
baseTemplates: function($ocLazyLoad) {
// here the template will be cached...
return $ocLazyLoad.loadTemplateFile(['base/dashboard.html']).then(function(){
console.log('test 1');
});
}
}
})
// console prints "test 2" before than "test 1"
Update: (+ Code updated)
I Think resolve section of my code has an issue. because it runs after template section! and it cause returning $templateCache.get being undefined.
I use ocLazyLoad plugin to cache template and it returns a correct promise.
Why template don't waits for resolve?