How could I use a name fetched from my database as a templateUrl filename?
I've tried this:
$stateProvider.state('/', {
url: '/',
views: {
page: {
controller: 'HomeCtrl',
templateProvider: function($templateFactory, $rootScope) {
console.log("$rootScope.template")
return $templateFactory.fromUrl('/templates/' + $rootScope.template);
}
}
}
});
Which doesn't seem to work work if my $rootScope.template comes from a database query. Don't know why, but it doesn't work.
If in my controller I do $rootScope.template = "whatever.html" everything works ok, but if I query the template from database nothing happens at all. console.log("$rootScope.template") in templateProvider gives me nothing (the query itself works just fine).
Does the query simply take too long and it's therefore not ready for the router or what's happening here?
That am I doing wrong and how can I fix it?