5

I want to change the ui-view templateUrl programatically from inside a controller because the templateUrl option does not support injection of services and I need a service to determine the template URL.

Thank you.

1 Answer 1

3

See the docs for templateProvider here:
"Quick Reference - template, templateUrl, templateProvider", Github - angular-ui/ui-router

Sign up to request clarification or add additional context in comments.

10 Comments

How can I change it from JS though? In the templateProvider I can only inject constants and providers. I can't inject services which I need to determine URL.
templateProvider: function(serviceName) { return serviceName.doWhatever(); }
You can't inject services in providers, can you?
templateProvider is a provider for the template path. It accepts normal injectable services.
Hm, I checked that before posing and it failed, but it might have been for other reasons. I'll give that a try, thank you.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.