Dynamically generate templateURL
I am trying to generate templatURL dynamically. I am using angularjs ui-routing
my routing function:
}).state('error',{
url: '/:locale/office-profile/',
templateUrl: function(obj) {
return 'partials/error-' + obj.locale + '.html';
}
I read other stackoverflow answers where they said they use a function like this. I am trying to get obj.locale to populate dynamically. I tried using $ stateParams.locale as I thought the url already has a locale, but that didn't work either.
When I do console.log (obj) it prints "Object: {locale: null}" and hence the template page cannot be loaded.
Please advise what I should do to achieve this. Thank you.
+3
source to share
No one has answered this question yet
Check out similar questions: